I am trying to compile an android app using boost 1-49's serialization library. Specifically, this project had some convenient scripts to get the job done: https://github.com/MysticTreeGames/Boost-for-Android
我正在尝试使用boost 1-49的序列化库来编译一个Android应用程序。具体来说,这个项目有一些方便的脚本来完成工作:https://github.com/MysticTreeGames/Boost-for-Android
Boost built without issue against the official ndk-r8, using gnu-libstdc++ 4.6 for armeabi-v7a.
使用gnu-libstdc ++ 4.6为armeabi-v7a构建了没有针对官方ndk-r8的问题。
At least, it was able to create libboost_serialization-gcc-mt-1_49.a without encountering any errors. Several warnings were thrown up during build, 'forbids zero-size array '_pad' [-pedantic]', 'does not support 'long long', 'does not permit named variadic macros', nothing that seemed serious, but I don't claim to be an expert on the gnu compiler.
至少,它能够创建libboost_serialization-gcc-mt-1_49.a而不会遇到任何错误。在构建期间抛出了几个警告,'禁止零大小的数组'_pad'[-pedantic]','不支持'long long','不允许命名的变量宏',没有什么看起来很严重,但我不知道声称自己是gnu编译器的专家。
Building boost also created libboost_wserialization-gcc-mt-1_49.a, which seemed odd, but is probably irrelevant. I did not include it in my makefiles.
构建boost也创建了libboost_wserialization-gcc-mt-1_49.a,这似乎很奇怪,但可能无关紧要。我没有将它包含在我的makefile中。
In any case, when I now 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
OK, I've made some progress on this over lunch. By actually digging into those src files in boost, I found that mbtowc and its reciprocal are part of gnu-libstdc++. So, somehow when I build boost it must not be getting the right references. Can't give it any more time over lunch, but I've looked at how boost was compiled, and the flags used should have linked everything appropriately.
好的,我在午餐时间取得了一些进展。通过实际挖掘boost中的那些src文件,我发现mbtowc及其倒数是gnu-libstdc ++的一部分。所以,不知何故,当我构建boost时,它一定不能得到正确的引用。午餐时间不能再给它了,但是我已经看过如何编译boost,并且使用的标志应该适当地连接所有内容。
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 edit
Given that I'm getting errors with the library, and that it's the only library that I use in code, I wouldn't think there could be a problem with makefiles. For the sake of thoroughness, though, here are there contents: Android.mk, included where I keep the compiled boost library:
鉴于我收到了库的错误,并且它是我在代码中使用的唯一库,我不认为makefile可能存在问题。但是为了彻底,这里有内容:Android.mk,包括我保存编译的boost库:
# 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, in proj.android/jni/
Android.mk,在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'm not building boost correctly, but can't say for sure. What could be causing those errors? I can't even seem to google the files that are allegedly referenced in the serialization library ('mbtowc' and permutations). Is it trying to reference the system or filesystem boost libraries, which I did not include via makefile?
我最好的猜测是我没有正确构建助推器,但不能肯定地说。什么可能导致这些错误?我甚至无法谷歌那些据称在序列化库中引用的文件('mbtowc'和permutations)。是否尝试引用系统或文件系统boost库,我没有通过makefile包含它?
2 个解决方案
#1
1
Boost serialization isn't supported on android-ndk-r8. I will look into crystaX r7 and see how that goes. The key difference is support for wchar, it seems. Here's hoping.
android-ndk-r8不支持Boost序列化。我将研究crystaX r7,看看它是怎么回事。看来,关键的区别是对wchar的支持。这是希望。
EDIT: OK, maybe it does. I don't know anymore. Depending who you ask, you might hear that the official ndk does support wchars, and its just a matter of managing boost's config files to know enough about the platform you're building to.
编辑:好的,也许吧。我不知道了。根据您的要求,您可能会听到官方的ndk确实支持wchars,而这只是管理boost的配置文件以了解您正在构建的平台。
Further, I'm also learning that apparently there are problems with boost crashing with crystaX's NDK.
此外,我也在了解到,使用crystaX的NDK可能会出现加速崩溃的问题。
Expect me back here next week saying, 'no no, actually I was right the second time, and half-right the fourth' /bitter
下周我会回到这里说'不,不,实际上我第二次是正确的,而第四次正确的一半'/苦
#2
0
I had the same problem. I was creating an android port for code that uses boost::serialization.
我有同样的问题。我正在为使用boost :: serialization的代码创建一个android端口。
My code did not use std::wstring or wchar_t anywhere.
我的代码没有在任何地方使用std :: wstring或wchar_t。
I compiled boost for android following the advice on this link: http://www.codexperiments.com/android/2011/05/tips-tricks-building-boost-with-ndk-r5/
我按照以下链接的建议编译了针对Android的boost:http://www.codexperiments.com/android/2011/05/tips-tricks-building-boost-with-ndk-r5/
I am using boost-1.55_0 and NDK r9c. And I had the same errors ->
我使用的是boost-1.55_0和NDK r9c。我也有同样的错误 - >
error: undefined reference to 'mbtowc' / error: undefined reference to 'wctomb'
错误:未定义引用'mbtowc'/错误:未定义引用'wctomb'
However I recompiled boost adding the following flag (via the jam configuration file):
但是我重新编译了boost添加以下标志(通过jam配置文件):
<compileflags>-DBOOST_NO_STD_WSTRING
This time the resulting library did not use mbtowc and serialization works for me.
这次生成的库没有使用mbtowc和序列化为我工作。
#1
1
Boost serialization isn't supported on android-ndk-r8. I will look into crystaX r7 and see how that goes. The key difference is support for wchar, it seems. Here's hoping.
android-ndk-r8不支持Boost序列化。我将研究crystaX r7,看看它是怎么回事。看来,关键的区别是对wchar的支持。这是希望。
EDIT: OK, maybe it does. I don't know anymore. Depending who you ask, you might hear that the official ndk does support wchars, and its just a matter of managing boost's config files to know enough about the platform you're building to.
编辑:好的,也许吧。我不知道了。根据您的要求,您可能会听到官方的ndk确实支持wchars,而这只是管理boost的配置文件以了解您正在构建的平台。
Further, I'm also learning that apparently there are problems with boost crashing with crystaX's NDK.
此外,我也在了解到,使用crystaX的NDK可能会出现加速崩溃的问题。
Expect me back here next week saying, 'no no, actually I was right the second time, and half-right the fourth' /bitter
下周我会回到这里说'不,不,实际上我第二次是正确的,而第四次正确的一半'/苦
#2
0
I had the same problem. I was creating an android port for code that uses boost::serialization.
我有同样的问题。我正在为使用boost :: serialization的代码创建一个android端口。
My code did not use std::wstring or wchar_t anywhere.
我的代码没有在任何地方使用std :: wstring或wchar_t。
I compiled boost for android following the advice on this link: http://www.codexperiments.com/android/2011/05/tips-tricks-building-boost-with-ndk-r5/
我按照以下链接的建议编译了针对Android的boost:http://www.codexperiments.com/android/2011/05/tips-tricks-building-boost-with-ndk-r5/
I am using boost-1.55_0 and NDK r9c. And I had the same errors ->
我使用的是boost-1.55_0和NDK r9c。我也有同样的错误 - >
error: undefined reference to 'mbtowc' / error: undefined reference to 'wctomb'
错误:未定义引用'mbtowc'/错误:未定义引用'wctomb'
However I recompiled boost adding the following flag (via the jam configuration file):
但是我重新编译了boost添加以下标志(通过jam配置文件):
<compileflags>-DBOOST_NO_STD_WSTRING
This time the resulting library did not use mbtowc and serialization works for me.
这次生成的库没有使用mbtowc和序列化为我工作。