android-ndk - 使用相互链接的预构建静态库

发布于 2024-12-08 14:08:08 字数 1152 浏览 0 评论 0原文

我想在共享库中使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

绻影浮沉 2024-12-15 14:08:08

天哪,事情就是这么简单。
对于遇到同样问题的任何人,我是这样解决的:

而不是

LOCAL_STATIC_LIBRARIES := tinySAK tinyNET tinyHTTP

使用含义。

LOCAL_STATIC_LIBRARIES := tinyHTTP tinyNET tinySAK

首先使用具有最多依赖性的含义,

My god, it was so simple.
To any of you with the same problem, heres how I solved it:

Instead of

LOCAL_STATIC_LIBRARIES := tinySAK tinyNET tinyHTTP

Use

LOCAL_STATIC_LIBRARIES := tinyHTTP tinyNET tinySAK

meaning, the one with the most dependencies first.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文