我想使用clang ++ - 3.5和CrystaX(10.1.0)的libC++来编译使用boost + ICU(使用boost的u32regex_match等)的本机组件。它在我的桌面机器上使用clang ++ - 3.5和libC++编译和链接很好。它编译罚款使用CrystaX,但我得到了一堆“未定义的引用”链接错误:CrystaX与clang ++和libC++链接错误与boost和icu
[[email protected]]computing/programming/crystax_test% rm -rf app/src/main/{obj,libs}; /home/powercf/Android/Ndk/ndk-build V=1 -C /home/powercf/computing/programming/crystax_test/app/src/main
make: Entering directory `/home/powercf/computing/programming/crystax_test/app/src/main'
rm -f ./libs/arm64-v8a/lib*.so ./libs/armeabi/lib*.so ./libs/armeabi-v7a/lib*.so ./libs/armeabi-v7a-hard/lib*.so ./libs/mips/lib*.so ./libs/x86/lib*.so ./libs/x86_64/lib*.so
rm -f ./libs/arm64-v8a/gdbserver ./libs/armeabi/gdbserver ./libs/armeabi-v7a/gdbserver ./libs/armeabi-v7a-hard/gdbserver ./libs/mips/gdbserver ./libs/x86/gdbserver ./libs/x86_64/gdbserver
rm -f ./libs/arm64-v8a/gdb.setup ./libs/armeabi/gdb.setup ./libs/armeabi-v7a/gdb.setup ./libs/armeabi-v7a-hard/gdb.setup ./libs/mips/gdb.setup ./libs/x86/gdb.setup ./libs/x86_64/gdb.setup
[armeabi] Compile++ thumb: test-boost <= test.cpp
/home/powercf/Android/crystax-ndk-10.1.0/toolchains/llvm-3.5/prebuilt/linux-x86_64/bin/clang++ -MMD -MP -MF ./obj/local/armeabi/objs/test-boost/test.o.d -gcc-toolchain /home/powercf/Android/crystax-ndk-10.1.0/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64 -fpic -ffunction-sections -funwind-tables -fstack-protector -Wno-invalid-command-line-argument -Wno-unused-command-line-argument -no-canonical-prefixes -fno-integrated-as -target armv5te-none-linux-androideabi -march=armv5te -mtune=xscale -msoft-float -fno-exceptions -fno-rtti -mthumb -Os -g -DNDEBUG -fomit-frame-pointer -fno-strict-aliasing -I/home/powercf/Android/crystax-ndk-10.1.0/sources/boost/1.57.0/include -I/home/powercf/Android/crystax-ndk-10.1.0/sources/icu/54.1/include -I/home/powercf/Android/crystax-ndk-10.1.0/sources/icu/54.1/include -I/home/powercf/Android/crystax-ndk-10.1.0/sources/icu/54.1/include -I/home/powercf/Android/crystax-ndk-10.1.0/sources/icu/54.1/include -I/home/powercf/Android/crystax-ndk-10.1.0/sources/cxx-stl/llvm-libc++/libcxx/include -I/home/powercf/Android/crystax-ndk-10.1.0/sources/cxx-stl/llvm-libc++/../llvm-libc++abi/libcxxabi/include -Ijni -DANDROID -Wa,--noexecstack -Wformat -Werror=format-security -std=c++11 -frtti -fexceptions -c -I/home/powercf/Android/crystax-ndk-10.1.0/sources/crystax/include -I/home/powercf/Android/crystax-ndk-10.1.0/platforms/android-3/arch-arm/usr/include jni/test.cpp -o ./obj/local/armeabi/objs/test-boost/test.o
[armeabi] SharedLibrary : libtest-boost.so
/home/powercf/Android/crystax-ndk-10.1.0/toolchains/llvm-3.5/prebuilt/linux-x86_64/bin/clang++ -Wl,-soname,libtest-boost.so -shared --sysroot=/home/powercf/Android/crystax-ndk-10.1.0/platforms/android-3/arch-arm ./obj/local/armeabi/objs/test-boost/test.o /home/powercf/Android/crystax-ndk-10.1.0/sources/boost/1.57.0/libs/armeabi/libboost_regex.a /home/powercf/Android/crystax-ndk-10.1.0/sources/icu/54.1/libs/armeabi/libicui18n.a /home/powercf/Android/crystax-ndk-10.1.0/sources/icu/54.1/libs/armeabi/libicuio.a /home/powercf/Android/crystax-ndk-10.1.0/sources/icu/54.1/libs/armeabi/libicuuc.a /home/powercf/Android/crystax-ndk-10.1.0/sources/icu/54.1/libs/armeabi/libicudata.a /home/powercf/Android/crystax-ndk-10.1.0/sources/cxx-stl/llvm-libc++/libs/armeabi/thumb/libc++_static.a -lgcc -gcc-toolchain /home/powercf/Android/crystax-ndk-10.1.0/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64 -no-canonical-prefixes -target armv5te-none-linux-androideabi -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -mthumb -L/home/powercf/Android/crystax-ndk-10.1.0/sources/crystax/empty /home/powercf/Android/crystax-ndk-10.1.0/sources/crystax/libs/armeabi/thumb/libcrystax.so -lc -o ./obj/local/armeabi/libtest-boost.so
/home/powercf/Android/crystax-ndk-10.1.0/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld: warning: hidden symbol '__cxa_call_unexpected' in /home/powercf/Android/crystax-ndk-10.1.0/sources/cxx-stl/llvm-libc++/libs/armeabi/thumb/libc++_static.a(cxa_personality.o) is referenced by DSO /home/powercf/Android/crystax-ndk-10.1.0/sources/crystax/libs/armeabi/thumb/libcrystax.so
/home/powercf/Android/crystax-ndk-10.1.0/sources/boost/1.57.0/libs/armeabi/libboost_regex.a(cpp_regex_traits.o):cpp_regex_traits.cpp:function boost::re_detail::cpp_regex_traits_char_layer<char>::init(): error: undefined reference to 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::string const&)'
/home/powercf/Android/crystax-ndk-10.1.0/sources/boost/1.57.0/libs/armeabi/libboost_regex.a(cpp_regex_traits.o):cpp_regex_traits.cpp:function boost::re_detail::cpp_regex_traits_char_layer<char>::init(): error: undefined reference to 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)'
/home/powercf/Android/crystax-ndk-10.1.0/sources/boost/1.57.0/libs/armeabi/libboost_regex.a(cpp_regex_traits.o):cpp_regex_traits.cpp:function boost::re_detail::cpp_regex_traits_char_layer<char>::init(): error: undefined reference to 'std::string::_M_leak_hard()'
/home/powercf/Android/crystax-ndk-10.1.0/sources/boost/1.57.0/libs/armeabi/libboost_regex.a(cpp_regex_traits.o):cpp_regex_traits.cpp:function boost::re_detail::cpp_regex_traits_char_layer<char>::init(): error: undefined reference to 'std::string::_Rep::_M_destroy(std::allocator<char> const&)'
/home/powercf/Android/crystax-ndk-10.1.0/sources/boost/1.57.0/libs/armeabi/libboost_regex.a(cpp_regex_traits.o):cpp_regex_traits.cpp:function boost::re_detail::cpp_regex_traits_char_layer<char>::init(): error: undefined reference to 'std::string::_Rep::_M_destroy(std::allocator<char> const&)'
/home/powercf/Android/crystax-ndk-10.1.0/sources/boost/1.57.0/libs/armeabi/libboost_regex.a(cpp_regex_traits.o):cpp_regex_traits.cpp:function boost::re_detail::cpp_regex_traits_char_layer<char>::init(): error: undefined reference to 'std::string::_Rep::_M_destroy(std::allocator<char> const&)'
等等,等等
我不是一个机器人,NDK,升压,ICU,crystaX或铛专家,但我猜CrystaX boost & icu库与clang不兼容?否则我错过了一些配置选项或什么?有没有什么办法让这个工作(g ++ + libstdC++也不适合我用相同的代码或std :: future,所以我没有使用它)?或者我需要看看编译自己的boost和icu for android(我宁愿避免)?
TEST.CPP:
Android.mk:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := test-boost
LOCAL_SRC_FILES := test.cpp
LOCAL_STATIC_LIBRARIES := boost_regex_static icui18n_static icuio_static icuuc_static icudata_static
LOCAL_CPP_FEATURES := rtti exceptions
include $(BUILD_SHARED_LIBRARY)
$(call import-module,boost/1.57.0)
$(call import-module,icu/54.1)
Application.mk:
NDK_TOOLCHAIN_VERSION := clang3.5
APP_STL := c++_static
我仍然得到与clang3.5链接错误,但它确实有4.9 gnustl,这是我猜解工作。希望有一天我们会得到完整的clang/libC++支持。保持良好的工作! – powercf
很高兴知道它适合你!不过,如果你能分享你使用clang3.5的链接器错误,我将不胜感激 - 是否与原始消息或其他内容中的错误相同? –
我得到这些错误中的四个,全部来自libboost_regex.a - 两个来自icu.cpp,两个来自instances.cpp: 'libboost_regex.a(icu.o):icu.cpp:函数boost :: re_detail :: basic_regex_parser :: parse_perl_extension():错误:未定义参照“的std :: __ throw_out_of_range_fmt(字符常量*,...)' 其他的都是如上述完全相同,除了与NDK_TOOLCHAIN_VERSION:= clang3。 5,APP_PLATFORM:=机器人-21,和LOCAL_STATIC_LIBRARIES:= icui18n_static icuio_static icuuc_static icudata_static boost_regex_static icui18n_static icuio_static icuuc_static icudata_static –
powercf