Boost C++ Libraries: Ticket #9657: Boost Log V2 Library Android Linking https://svn.boost.org/trac10/ticket/9657 <p> I am trying to build Boost 1.55 Log v2 library on Android using NDK 9C. I have used the patches and build the boost using build-android.sh including thread,iostreams,random and log options. I have used the other features of Boost and they have worked. But there seems to be linking problem with the Log V2 on NDK 9c 64 bit which I could not solve with the existing solutions. I keep getting the same "undefined reference" error. On the web people solved this problem including "#define BOOST_ALL_DYN_LINK" but it did not work for me. The build-android.sh file option LIBRARIES=--with-libraries=date_time,filesystem,program_options,regex,signals,system,thread,iostreams,random,log </p> <p> Console Output: </p> <pre class="wiki">10:35:45 **** Build of configuration Default for project BoostLogLib **** /home/guven/Desktop/IDP/adt/android-ndk-r9c/ndk-build all Android NDK: WARNING: APP_PLATFORM android-9 is larger than android:minSdkVersion 8 in ./AndroidManifest.xml Android NDK: WARNING:jni/Android.mk:BoostLogLib: non-system libraries in linker flags: /home/guven/Desktop/IDP/adt/android-ndk-r9c/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a/libgnustl_static.a -lboost_system-gcc-mt-1_55 -lboost_filesystem-gcc-mt-1_55 -lboost_thread-gcc-mt-1_55 -lboost_iostreams-gcc-mt-1_55 -lboost_date_time-gcc-mt-1_55 -lboost_random-gcc-mt-1_55 -lboost_log-gcc-mt-1_55 -lboost_log_setup-gcc-mt-1_55 -lboost_program_options-gcc-mt-1_55 -lboost_regex-gcc-mt-1_55 -lboost_chrono-gcc-mt-1_55 Android NDK: This is likely to result in incorrect builds. Try using LOCAL_STATIC_LIBRARIES Android NDK: or LOCAL_SHARED_LIBRARIES instead to list the library dependencies of the Android NDK: current module [armeabi-v7a] Compile++ thumb: BoostLogLib &lt;= BoostLogLib.cpp [armeabi-v7a] SharedLibrary : libBoostLogLib.so jni/BoostLogLib.cpp:20: error: undefined reference to 'boost::log::v2_mt_posix::core::get()' /home/guven/Desktop/IDP/workspace/3rdparty/Boost-for-Android/boost_1_55_0/boost/log/attributes/attribute_name.hpp:80: error: undefined reference to 'boost::log::v2_mt_posix::attribute_name::get_id_from_string(char const*)' jni/BoostLogLib.cpp:20: error: undefined reference to 'boost::log::v2_mt_posix::core::set_filter(boost::log::v2_mt_posix::filter const&amp;)' /home/guven/Desktop/IDP/workspace/3rdparty/Boost-for-Android/boost_1_55_0/boost/log/attributes/value_extraction.hpp:232: error: undefined reference to 'boost::log::v2_mt_posix::attribute_value_set::find(boost::log::v2_mt_posix::attribute_name) const' /home/guven/Desktop/IDP/workspace/3rdparty/Boost-for-Android/boost_1_55_0/boost/log/attributes/value_extraction.hpp:233: error: undefined reference to 'boost::log::v2_mt_posix::attribute_value_set::end() const' /home/guven/Desktop/IDP/workspace/3rdparty/Boost-for-Android/boost_1_55_0/boost/log/attributes/value_extraction.hpp:241: error: undefined reference to 'boost::log::v2_mt_posix::aux::attach_attribute_name_info(boost::exception&amp;, boost::log::v2_mt_posix::attribute_name const&amp;)' collect2: error: ld returned 1 exit status make: *** [obj/local/armeabi-v7a/libBoostLogLib.so] Error 1 10:35:50 Build Finished (took 4s.138ms) </pre><blockquote> <p> <a class="missing wiki">BoostLogLib</a>.h </p> </blockquote> <pre class="wiki">#ifndef BOOSTLOGLIB_H_ #define BOOSTLOGLIB_H_ #include &lt;jni.h&gt; #include &lt;iostream&gt; #ifdef __cplusplus extern "C" { #endif /* * Class: HelloWorld * Method: print * Signature: ()V */ JNIEXPORT jstring JNICALL Java_com_example_boostloglib_BoostLogLib_print (JNIEnv *, jobject); #ifdef __cplusplus } #endif #endif /* BOOSTLOGLIB_H_ */ </pre><p> <a class="missing wiki">BoostLogLib</a>.cpp </p> <pre class="wiki">#define BOOST_LOG_USE_CHAR #define BOOST_ALL_DYN_LINK #include "BoostLogLib.h" #include &lt;boost/log/core.hpp&gt; #include &lt;boost/log/trivial.hpp&gt; #include &lt;boost/log/expressions.hpp&gt; namespace logging = boost::log; //[ example_tutorial_trivial_with_filtering void init() { logging::core::get()-&gt;set_filter ( logging::trivial::severity &gt;= logging::trivial::info ); } int start_logging() { init(); return 0; } JNIEXPORT jstring JNICALL Java_com_example_boostloglib_BoostLogLib_print(JNIEnv * env, jobject obj){ start_logging(); jstring result = env-&gt;NewStringUTF("Hello world!!!"); // C style string to Java String return result; } </pre><p> Android.mk </p> <pre class="wiki">LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := BoostLogLib LOCAL_SRC_FILES := BoostLogLib.cpp LOCAL_CPP_EXTENSION := .cpp LOCAL_CPPFLAGS += -std=c++0x LOCAL_LDLIBS += $(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a/libgnustl_static.a LOCAL_CFLAGS += -lpthread LOCAL_CFLAGS += -I$(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.8/include LOCAL_CFLAGS += -I$(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a/include LOCAL_CFLAGS += -I/home/guven/Desktop/IDP/workspace/3rdparty/Boost-for-Android/boost_1_55_0 LOCAL_LDLIBS += -L/home/guven/Desktop/IDP/workspace/3rdparty/Boost-for-Android/build/lib -lboost_system-gcc-mt-1_55 -lboost_filesystem-gcc-mt-1_55 -lboost_thread-gcc-mt-1_55 -lboost_iostreams-gcc-mt-1_55 -lboost_date_time-gcc-mt-1_55 -lboost_random-gcc-mt-1_55 -lboost_log-gcc-mt-1_55 -lboost_log_setup-gcc-mt-1_55 -lboost_program_options-gcc-mt-1_55 -lboost_regex-gcc-mt-1_55 -lboost_chrono-gcc-mt-1_55 LOCAL_CPPFLAGS += -fexceptions LOCAL_CPPFLAGS += -frtti include $(BUILD_SHARED_LIBRARY) </pre><p> Application.mk </p> <pre class="wiki">APP_MODULES := BoostLogLib APP_ABI := armeabi-v7a APP_STL := gnustl_static APP_PLATFORM := android-9 NDK_TOOLCHAIN_VERSION := 4.8 APP_CPPFLAGS += -std=c++0x </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/9657 Trac 1.4.3 Guven <guveni@…> Tue, 11 Feb 2014 12:15:37 GMT keywords set https://svn.boost.org/trac10/ticket/9657#comment:1 https://svn.boost.org/trac10/ticket/9657#comment:1 <ul> <li><strong>keywords</strong> Log NDK 9C added </li> </ul> Ticket Guven <guveni@…> Thu, 13 Feb 2014 09:24:22 GMT <link>https://svn.boost.org/trac10/ticket/9657#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/9657#comment:2</guid> <description> <p> it seems that the problem is caused because of the static library linking The problem is that it looks for symbols like this: </p> <pre class="wiki">boost::log::v2_mt_posix::core::set_filter </pre><p> But instead the library has symbols: </p> <pre class="wiki">boost::log::v2s_mt_posix::core::set_filter </pre><p> if #define BOOST_ALL_DYN_LINK is removed and APP_STL is changed in Application.mk from gnustl_static to gnustl_shared. Then the problem goes away. But it should not be in this way. </p> <p> Note that it only applies if library is build as below </p> <pre class="wiki">./build-android.sh --boost=1.55.0 --with-libraries=date_time,filesystem,program_options,regex,signals,system,thread,iostreams,random,log,serialization,graph $PATH_TO_NDK </pre> </description> <category>Ticket</category> </item> </channel> </rss>