如何在使用ndk-build进行编译时指定要在Android.mk中加载的共享库?
修改:这是我的Android.mk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := lib-crypto
LOCAL_SRC_FILES := libcrypto.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := tema1
LOCAL_SRC_FILES := tema1.c
LOCAL_SHARED_LIBRARIES := lib-crypto
LOCAL_C_INCLUDES := /home/aleksei/openSSL0.9.8/include
include $(BUILD_EXECUTABLE)
libcrypto.so是我为android构建的库。我想用它制作一个程序。现在它给了我这个错误:
Install : libcrypto.so => libs/armeabi/libcrypto.so
Executable : tema1
./obj/local/armeabi/libcrypto.so: undefined reference to `dladdr'
collect2: ld returned 1 exit status
make: *** [obj/local/armeabi/tema1] Error 1
答案 0 :(得分:1)
PREBUILT_SHARED_LIBRARY
Points to a build script used to specify a prebuilt shared library.
Unlike BUILD_SHARED_LIBRARY and BUILD_STATIC_LIBRARY, the value
of LOCAL_SRC_FILES must be a single path to a prebuilt shared
library (e.g. foo/libfoo.so), instead of a source file.
You can reference the prebuilt library in another module using
the LOCAL_PREBUILTS variable (see docs/PREBUILTS.html for more
information).
从http://source-android.frandroid.com/ndk/docs/ANDROID-MK.html
了解详情告诉我你到底做了什么以及你面临问题的地方。?
答案 1 :(得分:1)
我遇到了同样的问题。为了解决这个问题,我做了以下几点:
"APP_PLATFORM := android-8"
如果您已有Application.mk文件,只需将步骤2中的代码添加到现有文件即可。现在调用ndk-build并查看它是否链接。 ndk-build可能正在使用没有dladdr()的旧版libdl进行编译。步骤2中的代码将导致ndk-build使用具有dladdr()的更新的libdl。