I am trying to using Poco C++ (PocoFoundation and PocoNet) for my Android application via NDK. I got these issues while building my project on 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
Here are my Application.mk:
NDK_TOOLCHAIN_VERSION := 4.8
APP_ABI := armeabi
APP_STL := gnustl_shared
APP_CPPFLAGS += -std=c++11 -pthread -frtti -fexceptions
and 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)
The Poco static libraries were built using standalone toolchain as in this link http://pocoproject.org/docs/99300-AndroidPlatformNotes.html#2.
Can anyone help me how to resolve these issues? Thank you.
I have found the cause of the linking problem. For PocoNet static library configuration in Android.mk, we need to add LOCAL_STATIC_LIBRARIES:= PocoFoundation
as PocoNet depends on PocoFoundation. My Android.mk for PocoNet part now is as below:
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)