gpt4 book ai didi

android - Poco C++ for Android 链接问题

转载 作者:行者123 更新时间:2023-11-30 04:02:28 25 4
gpt4 key购买 nike

我正在尝试通过 NDK 为我的 Android 应用程序使用 Poco C++(PocoFoundation 和 PocoNet)。我在 eclipse 上构建项目时遇到了这些问题:

[armeabi] Compile++ thumb: MySharedLib <= wrapper.cpp
[armeabi] SharedLibrary : libMySharedLib.so
src/IPAddress.cpp:127: error: undefined reference to 'Poco::NumberFormatter::append(std::string&, int)'
src/IPAddress.cpp:129: error: undefined reference to 'Poco::NumberFormatter::append(std::string&, int)'
src/IPAddress.cpp:131: error: undefined reference to 'Poco::NumberFormatter::append(std::string&, int)'
src/IPAddress.cpp:133: error: undefined reference to 'Poco::NumberFormatter::append(std::string&, int)'
src/SocketAddress.cpp:413: error: undefined reference to 'Poco::NumberParser::tryParseUnsigned(std::string const&, unsigned int&)'
collect2: error: ld returned 1 exit status

这是我的 Application.mk:

NDK_TOOLCHAIN_VERSION := 4.8
APP_ABI := armeabi
APP_STL := gnustl_shared
APP_CPPFLAGS += -std=c++11 -pthread -frtti -fexceptions

和Android.mk:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)
LOCAL_MODULE := sodium
LOCAL_SRC_FILES := prebuild/libsodium.a
LOCAL_EXPORT_C_INCLUDES := include
include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE := PocoFoundation
LOCAL_SRC_FILES := prebuild/libPocoFoundation.a
LOCAL_EXPORT_C_INCLUDES := include
include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE := PocoNet
LOCAL_SRC_FILES := prebuild/libPocoNet.a
LOCAL_EXPORT_C_INCLUDES := include
include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE := MyStaticLib
LOCAL_SRC_FILES := prebuild/libMyStaticLib.a
LOCAL_EXPORT_C_INCLUDES := include
LOCAL_STATIC_LIBRARIES := sodium PocoFoundation PocoNet
include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE := MySharedLib
LOCAL_SRC_FILES := wrapper.cpp
LOCAL_C_INCLUDES += $(LOCAL_PATH)/include
LOCAL_LDLIBS := -ldl -llog
LOCAL_STATIC_LIBRARIES := MyStaticLib
include $(BUILD_SHARED_LIBRARY)

Poco 静态库是使用此链接中的独立工具链构建的 http://pocoproject.org/docs/99300-AndroidPlatformNotes.html#2 .

谁能帮我解决这些问题?谢谢。

最佳答案

我已经找到链接问题的原因。对于Android.mk中的PocoNet静态库配置,我们需要添加LOCAL_STATIC_LIBRARIES:= PocoFoundation,因为PocoNet依赖于PocoFoundation。我现在用于 PocoNet 部分的 Android.mk 如下所示:

include $(CLEAR_VARS)
LOCAL_MODULE := PocoNet
LOCAL_SRC_FILES := prebuild/libPocoNet.a
LOCAL_EXPORT_C_INCLUDES := include
LOCAL_STATIC_LIBRARIES:= PocoFoundation
include $(PREBUILT_STATIC_LIBRARY)

关于android - Poco C++ for Android 链接问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25050220/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com