Issue
I am trying to link in a static library using an Android.mk, but am getting the following error.
/home/pep/tools/crystax-ndk-10.3.2/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-g++ -Wl,--gc-sections -Wl,-z,nocopyreloc --sysroot=/home/pep/tools/crystax-ndk-10.3.2/platforms/android-21/arch-arm -Wl,-rpath-link=/home/pep/tools/crystax-ndk-10.3.2/platforms/android-21/arch-arm/usr/lib -Wl,-rpath-link=/home/pep/workspace/elm/src/agents/viga/obj/local/armeabi-v7a /home/pep/workspace/elm/src/agents/viga/obj/local/armeabi-v7a/objs/van/main.o -lgcc /home/pep/workspace/elm/src/agents/viga/obj/local/armeabi-v7a/libecom.so /home/pep/workspace/elm/src/agents/viga/obj/local/armeabi-v7a/libgnustl_shared.so -no-canonical-prefixes -march=armv7-a -Wl,--fix-cortex-a8 -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -fPIE -pie -mthumb -L/home/pep/tools/ros-android-ndk/roscpp_android/output/roscpp_android_ndk/lib /home/pep/tools/crystax-ndk-10.3.2/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/libsupc++.a -L/home/pep/tools/crystax-ndk-10.3.2/sources/crystax/empty /home/pep/tools/crystax-ndk-10.3.2/sources/crystax/libs/armeabi-v7a/thumb/libcrystax.so -lc -o /home/pep/workspace/elm/src/agents/viga/obj/local/armeabi-v7a/van
/home/pep/workspace/elm/src/agents/viga/jni/main.cpp:34: error: undefined reference to 'ros::init(int&, char**, std::string const&, unsigned int)'
collect2: error: ld returned 1 exit status
It would appear that the library is just not being linked in, no -l, but AFAIK, this is being included correctly using LOCAL_STATIC_LIBRARIES. I've tried listing it as libroscpp as well as -lroscpp. Here is the Android.mk.
LOCAL_PATH := $(call my-dir)
MY_ELM_HOME := /home/pep/workspace/elm/src
MY_ELM_INCL := /home/pep/workspace/elm/src/includes
MY_ROS_HOME := /home/pep/tools/ros-android-ndk/roscpp_android/output/roscpp_android_ndk
MY_COMMONS_INCL := $(MY_ELM_HOME)/includes/commons
MY_COMMONS_LIBS := $(MY_ELM_HOME)/libs/commons/libs/armeabi-v7a
MY_ROS_INCL := $(MY_ROS_HOME)/include
MY_ROS_LIBS := $(MY_ROS_HOME)/lib
include $(CLEAR_VARS)
LOCAL_MODULE := mycom
LOCAL_SRC_FILES := $(MY_COMMONS_LIBS)/libecom.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := van
LOCAL_C_INCLUDES := $(MY_ELM_INCL)
LOCAL_C_INCLUDES += $(MY_ROS_INCL)
LOCAL_SRC_FILES := main.cpp
LOCAL_CPPFLAGS := -std=gnu++14
LOCAL_CPP_FEATURES := rtti exceptions
LOCAL_LDLIBS := -L$(MY_ROS_LIBS)
LOCAL_SHARED_LIBRARIES := mycom
LOCAL_STATIC_LIBRARIES := libroscpp
LOCAL_STATIC_LIBRARIES += libroscpp_serialization
LOCAL_STATIC_LIBRARIES += librosconsole
include $(BUILD_EXECUTABLE)
$(call import-module,boost/1.59.0)
I've tried using -lroscpp with LOCAL_LDLIBS, but I get an error and a messsage saying to use LOCAL_STATIC_LIBRARIES. I'm certain the path is correct to the static lib.
And here is the symbols in the libroscpp.a.
$ nm -Ca ./libroscpp.a | grep "ros::init"
... <snip>
00000001 T ros::init(int&, char**, std::string const&, unsigned int)
... <snip>
I've also tried reordering the libs, but to no avail.
Thoughts?
Solution
for including static libraries (*.a) there is a PREBUILD_STATIC_LIBRARY that is used like with shared one, that is you need to make module like with libecom.so
Answered By - V-master
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.