Reputation: 8395
I've successfully built some of the boost-libraries but when I include them in a test project I get link errors.
Gdbserver : [arm-linux-androideabi-4.4.3] libs/armeabi/gdbserver
Gdbsetup : libs/armeabi/gdb.setup
Compile++ thumb : hello-jni <= test.cpp
SharedLibrary : libhello-jni.so
libboost_timer.a(cpu_timer.o): In function `~basic_iostream':
/opt/android-ndk-r7/sources/boost/../../sources/cxx-stl/gnu-libstdc++/include/istream:795: undefined reference to `VTT for std::basic_stringstream<char, std::char_traits<char>, std::allocator<char> >'
libboost_timer.a(cpu_timer.o): In function `show_time':
/opt/android-ndk-r7/sources/boost/libs/timer/src/cpu_timer.cpp:61: undefined reference to `VTT for std::basic_stringstream<char, std::char_traits<char>, std::allocator<char> >'
/opt/android-ndk-r7/sources/boost/libs/timer/src/cpu_timer.cpp:61: undefined reference to `vtable for std::basic_stringstream<char, std::char_traits<char>, std::allocator<char> >'
/opt/android-ndk-r7/sources/boost/libs/timer/src/cpu_timer.cpp:61: undefined reference to `vtable for std::basic_stringbuf<char, std::char_traits<char>, std::allocator<char> >'
libboost_timer.a(cpu_timer.o): In function `boost::timer::format(boost::timer::cpu_times const&, short, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
/opt/android-ndk-r7/sources/boost/libs/timer/src/cpu_timer.cpp:177: undefined reference to `std::basic_stringstream<char, std::char_traits<char>, std::allocator<char> >::~basic_stringstream()'
collect2: ld returned 1 exit status
Application.mk
APP_STL := gnustl_static
APP_CPPFLAGS = -fexceptions
Android.mk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := hello-jni
LOCAL_SRC_FILES := hello-jni.c test.cpp
LOCAL_STATIC_LIBRARIES := boost_timer, boost_system
LOCAL_LDLIBS := libboost_system.a libboost_timer.a libboost_chrono.a libboost_iostreams.a
include $(BUILD_SHARED_LIBRARY)
$(call import-module,boost)
And test.cpp
#include "test.hpp"
#include <string>
#include <boost/timer/timer.hpp>
void mytest() {
boost::timer::cpu_timer t;
}
Upvotes: 2
Views: 1606
Reputation: 800
we had very similar problem. What helped for us is to add -lgnustl_static
at the end of the LOCAL_LDLIBS line in Android.mk. Like this:
LOCAL_LDIBS := -lboost_system .... -lgnustl_static
I think this is because boost libraries depend on STL but don't have it statically compiled in, so it needs to be mentioned explicitly like that.
Also, it seems you don't have to add the APP_STL := gnustl_static
line to the Application.mk
.
Upvotes: 1