Adding library to NDK project - eclipse

282 Views Asked by At

Eclipse NDK, NativeActivity project. I ma trying to add a liquidfun(Box2D) library to my existing project. Unfortunately, no one in internet explain how to precisely do. I'am stuck after building library using ndk (following this https://google.github.io/liquidfun/Building/html/md__building_android.html), and run sample project. I have totally no idea how to use it in my own project. My Android.mk, i already using sfml.

  LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE    := sfml-example


PROJECT_FILES := $(wildcard $(LOCAL_PATH)/CPP/*.cpp)
PROJECT_FILES := $(PROJECT_FILES:$(LOCAL_PATH)/%=%)

LOCAL_SRC_FILES := main.cpp 

LOCAL_SRC_FILES += $(PROJECT_FILES)

FILE_LIST := $(wildcard $(LOCAL_PATH)*.cpp)

LOCAL_SHARED_LIBRARIES := sfml-system
LOCAL_SHARED_LIBRARIES += sfml-window
LOCAL_SHARED_LIBRARIES += sfml-graphics
LOCAL_SHARED_LIBRARIES += sfml-audio
LOCAL_SHARED_LIBRARIES += sfml-network
LOCAL_WHOLE_STATIC_LIBRARIES := sfml-main

include $(BUILD_SHARED_LIBRARY)

$(call import-module,sfml)

Thanks in advance.

1

There are 1 best solutions below

0
On

I have some prebuild libraries in my own project, and i include them like:

include $(CLEAR_VARS)
LOCAL_MODULE    := libcurl
LOCAL_SRC_FILES := lib/$(TARGET_ARCH_ABI)/libcurl.a
LOCAL_STATIC_LIBRARIES := libcares libssl
LOCAL_EXPORT_LDLIBS := -lz
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/curl/include
include $(PREBUILT_STATIC_LIBRARY)

this is for prebuilt static library (with .a extension). If you would like to include shared, just change it to BUILD_SHARED_LIBRARY. This file to include is inside MyProject/jni/lib/{arch} folder (with other libraries) and header files of library are put inside MyProject/jni/curl/include (just like it is visible in LOCAL_EXPORT_C_INCLUDES variable)

the names you pass to LOCAL_STATIC_LIBRARIES must be same as one that are declared in LOCAL_MODULE of other libraries/modules.

also everything you will probably need you can find in NDK docs that are in NDK folder. For prebuilt libraries there is separate section.