[Boost-bugs] [Boost C++ Libraries] #9657: Boost Log V2 Library Android Linking

Subject: [Boost-bugs] [Boost C++ Libraries] #9657: Boost Log V2 Library Android Linking
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2014-02-11 12:14:29


#9657: Boost Log V2 Library Android Linking
------------------------------+------------------------------
 Reporter: Guven <guveni@…> | Type: Bugs
   Status: new | Milestone: To Be Determined
Component: Building Boost | Version: Boost 1.55.0
 Severity: Problem | Keywords:
------------------------------+------------------------------
 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


 Console Output:

 {{{
 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 <= 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&)'
 /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&,
 boost::log::v2_mt_posix::attribute_name const&)'
 collect2: error: ld returned 1 exit status
 make: *** [obj/local/armeabi-v7a/libBoostLogLib.so] Error 1

 10:35:50 Build Finished (took 4s.138ms)
 }}}

  BoostLogLib.h


 {{{
 #ifndef BOOSTLOGLIB_H_
 #define BOOSTLOGLIB_H_

 #include <jni.h>

 #include <iostream>

 #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_ */
 }}}

 BoostLogLib.cpp


 {{{
 #define BOOST_LOG_USE_CHAR
 #define BOOST_ALL_DYN_LINK

 #include "BoostLogLib.h"


 #include <boost/log/core.hpp>
 #include <boost/log/trivial.hpp>
 #include <boost/log/expressions.hpp>

 namespace logging = boost::log;

 //[ example_tutorial_trivial_with_filtering
 void init()
 {
     logging::core::get()->set_filter
     (
         logging::trivial::severity >= 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->NewStringUTF("Hello world!!!"); // C style
 string to Java String
     return result;
 }
 }}}

 Android.mk

 {{{
 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)
 }}}
 Application.mk

 {{{
 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
 }}}

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/9657>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:15 UTC