I am trying to compile an Android application using boost serialization library 1-49. In particular, this project had some handy scripts to do the job: https://github.com/MysticTreeGames/Boost-for-Android
Boost is built without problems against the official ndk-r8, using gnu-libstdc ++ 4.6 for armeabi-v7a.
At least he was able to create libboost_serialization-gcc-mt-1_49.a without any errors. During the build, several warnings were thrown, “prohibits the zero-size array” _pad '[-pedantic]', 'does not support long long', 'does not allow the named variable macros', nothing serious, but I don’t know, t pretend to be an expert in the gnu compiler.
Building boost also created libboost_wserialization-gcc-mt-1_49.a, which seemed weird but probably doesn't matter. I did not include it in my makefiles.
Anyway, when I try to compile my code using this library, I get the following errors:
/Users/wespaugh/Development/android-ndk-r8d/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: ./obj/local/armeabi/libboost_serialization-gcc-mt-1_49.a(xml_iarchive.o): in function boost::archive::xml_iarchive_impl<boost::archive::xml_iarchive>::load(std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >&):./boost/archive/impl/xml_iarchive_impl.ipp:71: error: undefined reference to 'mbtowc' /Users/wespaugh/Development/android-ndk-r8d/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: ./obj/local/armeabi/libboost_serialization-gcc-mt-1_49.a(xml_iarchive.o): in function boost::archive::xml_iarchive_impl<boost::archive::xml_iarchive>::load(wchar_t*):./boost/archive/impl/xml_iarchive_impl.ipp:101: error: undefined reference to 'mbtowc' /Users/wespaugh/Development/android-ndk-r8d/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: ./obj/local/armeabi/libboost_serialization-gcc-mt-1_49.a(xml_iarchive.o): in function boost::archive::xml_iarchive_impl<boost::archive::naked_xml_iarchive>::load(std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >&):./boost/archive/impl/xml_iarchive_impl.ipp:71: error: undefined reference to 'mbtowc' /Users/wespaugh/Development/android-ndk-r8d/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: ./obj/local/armeabi/libboost_serialization-gcc-mt-1_49.a(xml_iarchive.o): in function boost::archive::xml_iarchive_impl<boost::archive::naked_xml_iarchive>::load(wchar_t*):./boost/archive/impl/xml_iarchive_impl.ipp:101: error: undefined reference to 'mbtowc' /Users/wespaugh/Development/android-ndk-r8d/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: ./obj/local/armeabi/libboost_serialization-gcc-mt-1_49.a(xml_oarchive.o): in function boost::archive::iterators::ostream_iterator<char> std::__copy_move<false, false, std::input_iterator_tag>::__copy_m<boost::archive::iterators::mb_from_wchar<boost::archive::iterators::xml_escape<wchar_t const*> >, boost::archive::iterators::ostream_iterator<char> >(boost::archive::iterators::mb_from_wchar<boost::archive::iterators::xml_escape<wchar_t const*> >, boost::archive::iterators::mb_from_wchar<boost::archive::iterators::xml_escape<wchar_t const*> >, boost::archive::iterators::ostream_iterator<char>):./boost/archive/iterators/mb_from_wchar.hpp:91: error: undefined reference to 'wctomb' collect2: ld returned 1 exit status
EDIT
Well, I made some progress on this over dinner. Actually digging into these src files in boost, I found that mbtowc and its inverses are part of gnu-libstdc ++. So, somehow, when I build boost, it should not get the right links. I can’t give more time for lunch, but I looked at how boost was compiled, and the flags used should have correctly bound everything.
From the build log:
Building with TOOLSET=gcc-androidR8 CXXPATH=/Users/wespaugh/Development/android-ndk-r8d/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86/bin/arm-linux-androideabi-g++ CXXFLAGS=-I/Users/wespaugh/Development/android-ndk-r8d/platforms/android-14/arch-arm/usr/include -I/Users/wespaugh/Development/android-ndk-r8d/sources/cxx-stl/gnu-libstdc++/4.6/include -I/Users/wespaugh/Development/android-ndk-r8d/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi-v7a/include
End editing
Given that I get errors in the library, and that this is the only library that I use in the code, I would not think that there might be a problem with make files. However, for the sake of thoroughness, there is content here: Android.mk, including where I store the compiled boost library:
# define module to include serialization static library LOCAL_PATH:= $(call my-dir) # serialization include $(CLEAR_VARS) LOCAL_CFLAGS += -I$(LOCAL_PATH)/include/boost-1_49 # -L$(LOCAL_PATH)/lib/ LOCAL_LDLIBS += -lboost_serialization \ -L$(NDK_ROOT)/sources/cxx-stl/ gnu-libstdc++/4.6/libs/armeabi-v7a \ -lgnustl_static LOCAL_CPPFLAGS += -fexceptions LOCAL_CPPFLAGS += -frtti LOCAL_CPP_EXTENSION := .cpp .hpp LOCAL_C_INCLUDES := $(LOCAL_PATH)/include/boost-1_49 \ $(LOCAL_PATH)/include/boost-1_49/boost/archive \ $(LOCAL_PATH)/include/boost-1_49/boost/serialization LOCAL_MODULE:= boost_serialization LOCAL_SRC_FILES:= lib/libboost_serialization-gcc-mt-1_49.a LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../../../Classes include $(PREBUILT_STATIC_LIBRARY)
Android.mk at proj.android/jni/
# compile the app LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LDFLAGS= -L$(NDK_ROOT)/sources/crystax/libs/armeabi-v7a/4.6.3 -Lcrystax LOCAL_CPPFLAGS += -fexceptions LOCAL_CPPFLAGS += -frtti LOCAL_MODULE := game_shared LOCAL_MODULE_FILENAME := libgame LOCAL_SRC_FILES := hellocpp/main.cpp \ ../../Classes/AppDelegate.cpp \ ../../Classes/HelloWorldScene.cpp LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes \ $(LOCAL_PATH)/../../../cocos2dx/platform/third_party/android/prebuilt/libboost/include/boost-1_49 \ $(LOCAL_PATH)/../../../cocos2dx/platform/third_party/android/prebuilt/libboost/include/boost-1_49/boost/archive \ $(LOCAL_PATH)/../../../cocos2dx/platform/third_party/android/prebuilt/libboost/include/boost-1_49/boost/serialization LOCAL_WHOLE_STATIC_LIBRARIES := boost_serialization cocos2dx_static cocosdenshion_static cocos_extension_static include $(BUILD_SHARED_LIBRARY) $(call import-module,CocosDenshion/android) \ $(call import-module,cocos2dx) $(call import-module,libboost)
My best guess is that I am not building the momentum correctly, but I cannot say for sure. What could be causing these errors? I can’t even imagine Google files that are allegedly mentioned in the serialization library ("mbtowc" and permutations). Is he trying to reference system acceleration libraries or file systems that I did not include through the make file?