android-ndk - 使用相互链接的预构建静态库
我想在共享库中使用 3 个预构建的静态库。
问题是当 ndk-build 尝试链接到静态库时,我收到大量未定义的引用。 “未定义的引用”源于静态库尝试调用另一个静态库中的方法时。例如,tinyNET调用tinySAK中的方法。依赖关系是这样的: tinySAK 没有依赖项 tinyNET依赖于tinySAK, tinyHTTP 依赖于tinyNET 和tinySAK
这是我的Android.mk 的样子:
LOCAL_PATH := $(call my-dir)
# TINYSAK
include $(CLEAR_VARS)
LOCAL_MODULE := tinySAK
LOCAL_SRC_FILES := libtinySAK_armv7-a.a
include $(PREBUILT_STATIC_LIBRARY)
# TINYNET
include $(CLEAR_VARS)
LOCAL_MODULE := tinyNET
LOCAL_SRC_FILES := libtinyNET_armv7-a.a
include $(PREBUILT_STATIC_LIBRARY)
# TINYHTTP
include $(CLEAR_VARS)
LOCAL_MODULE := tinyHTTP
LOCAL_SRC_FILES := libtinyHTTP_armv7-a.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libtest
LOCAL_SRC_FILES := \
/../../testclient.cpp \
/../../main.cpp \
/../../Webservice.cpp
LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/../../includes/ \
$(LOCAL_PATH)/../../../doubango/tinyHTTP/include/ \
$(LOCAL_PATH)/../../../doubango/tinySAK/src/ \
$(LOCAL_PATH)/../../../doubango/tinyNET/src/
LOCAL_STATIC_LIBRARIES := tinySAK tinyNET tinyHTTP
include $(BUILD_SHARED_LIBRARY)
我应该做什么来解决这个问题?
I've got 3 prebuilt static libraries I want to use in my shared library.
The problem is when the ndk-build
tries to link to the static libraries, I get tons of undefined references thrown at me.
The 'undefined references' originates from when the static libraries tries to call methods in another static library. For example, tinyNET calling a method in tinySAK. The dependencies are this:
tinySAK has no dependencies
tinyNET depends on tinySAK,
tinyHTTP depends on tinyNET and tinySAK
Here's what my Android.mk looks like:
LOCAL_PATH := $(call my-dir)
# TINYSAK
include $(CLEAR_VARS)
LOCAL_MODULE := tinySAK
LOCAL_SRC_FILES := libtinySAK_armv7-a.a
include $(PREBUILT_STATIC_LIBRARY)
# TINYNET
include $(CLEAR_VARS)
LOCAL_MODULE := tinyNET
LOCAL_SRC_FILES := libtinyNET_armv7-a.a
include $(PREBUILT_STATIC_LIBRARY)
# TINYHTTP
include $(CLEAR_VARS)
LOCAL_MODULE := tinyHTTP
LOCAL_SRC_FILES := libtinyHTTP_armv7-a.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libtest
LOCAL_SRC_FILES := \
/../../testclient.cpp \
/../../main.cpp \
/../../Webservice.cpp
LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/../../includes/ \
$(LOCAL_PATH)/../../../doubango/tinyHTTP/include/ \
$(LOCAL_PATH)/../../../doubango/tinySAK/src/ \
$(LOCAL_PATH)/../../../doubango/tinyNET/src/
LOCAL_STATIC_LIBRARIES := tinySAK tinyNET tinyHTTP
include $(BUILD_SHARED_LIBRARY)
What should I do to fix this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
天哪,事情就是这么简单。
对于遇到同样问题的任何人,我是这样解决的:
而不是
使用含义。
首先使用具有最多依赖性的含义,
My god, it was so simple.
To any of you with the same problem, heres how I solved it:
Instead of
Use
meaning, the one with the most dependencies first.