- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我想使用 CrystaX (10.1.0) 中的 clang++-3.5 和 libc++ 来编译使用 boost + ICU(使用 boost 的 u32regex_match 等)的 native 组件。它在我的桌面机器上使用 clang++-3.5 和 libc++ 编译和链接良好。它使用 CrystaX 编译得很好,但我收到一堆“ undefined reference ”链接错误:
[powercf@powercf-desktop]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&)'
等等等
我不是 android、NDK、boost、icu、crystaX 或 clang 专家,但我猜 CrystaX boost 和 icu 库与 clang 并不真正兼容?或者我缺少一些配置选项或其他东西?有什么方法可以使它正常工作(g++ + libstdc++ 也不适用于我使用相同的代码或 std::future 所以我没有使用它)?或者我是否需要考虑为 android 编译我自己的 boost 和 icu(我宁愿避免)?
测试.cpp:
#include <jni.h>
#include <iostream>
#include <boost/regex.hpp>
#include <boost/regex/icu.hpp>
#include <unicode/unistr.h>
#include <unicode/ustream.h>
extern "C" jlong Java_com_powercf_examples_crystax_test_MainActivity_Foobie(JNIEnv* env, jobject thiz, jstring s)
{
boost::regex regex1("hello");
std::string input_str1("test");
bool match = boost::regex_match(input_str1, regex1);
UnicodeString regex_str = "tea";
UnicodeString input_str2 = "coffee";
boost::u32regex regex2 = boost::make_u32regex(regex_str);
match = boost::u32regex_match(input_str2, regex2);
return match;
}
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)
应用程序.mk:
NDK_TOOLCHAIN_VERSION := clang3.5
APP_STL := c++_static
最佳答案
发生这种情况是因为 LLVM libc++ 与 GNU libstdc++ 二进制不兼容,并且 CrystaX NDK 中的 Boost 是针对 GNU libstdc++ 构建和链接的。修复它的唯一方法是使用 LLVM libc++ 构建 Boost,这应该不会太难,但它完全未经测试。我已经提交了 ticket在 CrystaX NDK 中执行此操作,但实际上目前最快的方法是使用 GNU libstdc++ 作为 C++ 标准库实现(它适用于 clang)。
换句话说,您的 Application.mk 应该如下所示:
NDK_TOOLCHAIN_VERSION := clang3.5
APP_STL := gnustl_static
关于android - 带有 clang++ 和 libc++ 的 CrystaX 与 boost 和 icu 的链接错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30870938/
我已经使用 vue-cli 两个星期了,直到今天一切正常。我在本地建立这个项目。 https://drive.google.com/open?id=0BwGw1zyyKjW7S3RYWXRaX24tQ
您好,我正在尝试使用 python 库 pytesseract 从图像中提取文本。请找到代码: from PIL import Image from pytesseract import image_
我的错误 /usr/bin/ld: errno: TLS definition in /lib/libc.so.6 section .tbss mismatches non-TLS reference
我已经训练了一个模型,我正在尝试使用 predict函数但它返回以下错误。 Error in contrasts<-(*tmp*, value = contr.funs[1 + isOF[nn]])
根据Microsoft DataConnectors的信息我想通过 this ODBC driver 创建一个从 PowerBi 到 PostgreSQL 的连接器使用直接查询。我重用了 Micros
我已经为 SoundManagement 创建了一个包,其中有一个扩展 MediaPlayer 的类。我希望全局控制这个变量。这是我的代码: package soundmanagement; impo
我在Heroku上部署了一个应用程序。我正在使用免费服务。 我经常收到以下错误消息。 PG::Error: ERROR: out of memory 如果刷新浏览器,就可以了。但是随后,它又随机发生
我正在运行 LAMP 服务器,这个 .htaccess 给我一个 500 错误。其作用是过滤关键字并重定向到相应的域名。 Options +FollowSymLinks RewriteEngine
我有两个驱动器 A 和 B。使用 python 脚本,我在“A”驱动器中创建一些文件,并运行 powerscript,该脚本以 1 秒的间隔将驱动器 A 中的所有文件复制到驱动器 B。 我在 powe
下面的函数一直返回这个错误信息。我认为可能是 double_precision 字段类型导致了这种情况,我尝试使用 CAST,但要么不是这样,要么我没有做对...帮助? 这是错误: ERROR: i
这个问题已经有答案了: Syntax error due to using a reserved word as a table or column name in MySQL (1 个回答) 已关闭
我的数据库有这个小问题。 我创建了一个表“articoli”,其中包含商品的品牌、型号和价格。 每篇文章都由一个 id (ID_ARTICOLO)` 定义,它是一个自动递增字段。 好吧,现在当我尝试插
我是新来的。我目前正在 DeVry 在线学习中级 C++ 编程。我们正在使用 C++ Primer Plus 这本书,到目前为止我一直做得很好。我的老师最近向我们扔了一个曲线球。我目前的任务是这样的:
这个问题在这里已经有了答案: What is an undefined reference/unresolved external symbol error and how do I fix it?
我的网站中有一段代码有问题;此错误仅发生在 Internet Explorer 7 中。 我没有在这里发布我所有的 HTML/CSS 标记,而是发布了网站的一个版本 here . 如您所见,我在列中有
如果尝试在 USB 设备上构建 node.js 应用程序时在我的树莓派上使用 npm 时遇到一些问题。 package.json 看起来像这样: { "name" : "node-todo",
在 Python 中,您有 None单例,在某些情况下表现得很奇怪: >>> a = None >>> type(a) >>> isinstance(a,None) Traceback (most
这是我的 build.gradle (Module:app) 文件: apply plugin: 'com.android.application' android { compileSdkV
我是 android 的新手,我的项目刚才编译和运行正常,但在我尝试实现抽屉导航后,它给了我这个错误 FAILURE: Build failed with an exception. What wen
谁能解释一下?我想我正在做一些非常愚蠢的事情,并且急切地等待着启蒙。 我得到这个输出: phpversion() == 7.2.25-1+0~20191128.32+debian8~1.gbp108
我是一名优秀的程序员,十分优秀!