错误对'std ::

编程入门 行业动态 更新时间:2024-10-09 03:31:56
本文介绍了错误对'std :: __ ndk1 :: locale ::〜locale()的未定义引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在使用 Boost for Android 和Android Studio NDK.我正在使用来自boost的库之一libboost_filesystem-clang-mt-a32-1_66.a,但是显示以下错误:

I have an issue when compiling my code using Boost for Android with Android Studio ndk. I am using one of the libraries libboost_filesystem-clang-mt-a32-1_66.a from boost, however, it shows following error:

FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':app:externalNativeBuildDebug'. > Build command failed. Error while executing process /home/user/Android/Sdk/cmake/3.6.4111459/bin/cmake with arguments {--build /home/user/git/project/app/.externalNativeBuild/cmake/debug/armeabi-v7a --target native-lib} [1/2] Building CXX object CMakeFiles/native-lib.dir/src/main/cpp/native-lib.cpp.o [2/2] Linking CXX shared library ../../../../build/intermediates/cmake/debug/obj/armeabi-v7a/libnative-lib.so FAILED: : && /home/user/Downloads/android-ndk-r16b/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-g++ --sysroot=/home/user/Downloads/android-ndk-r16b/sysroot -fPIC -isystem /home/user/Downloads/android-ndk-r16b/sysroot/usr/include/arm-linux-androideabi -D__ANDROID_API__=23 -g -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb -mfpu=neon -Wa,--noexecstack -Wformat -Werror=format-security -std=c++11 -Wno-error=format-security -fpermissive -fopenmp -Og -fopenmp -O0 -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libatomic.a --sysroot /home/user/Downloads/android-ndk-r16b/platforms/android-23/arch-arm -Wl,--build-id -Wl,--warn-shared-textrel -Wl,--fatal-warnings -Wl,--fix-cortex-a8 -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -shared -Wl,-soname,libnative-lib.so -o ../../../../build/intermediates/cmake/debug/obj/armeabi-v7a/libnative-lib.so CMakeFiles/native-lib.dir/src/main/cpp/native-lib.cpp.o -L/home/user/git/project/app/src/main/cpp/libs -laltumfacerecognizesdk_android -laltumfacedetectsdk_android ../../../../src/main/jniLibs/armeabi-v7a/libopencv_java.so /home/user/git/project/OpenCV-android-sdk/sdk/native/libs/armeabi-v7a/libopencv_core.a /home/user/git/project/OpenCV-android-sdk/sdk/native/libs/armeabi-v7a/libopencv_highgui.a /home/user/git/project/OpenCV-android-sdk/sdk/native/libs/armeabi-v7a/libopencv_imgproc.a /home/user/git/project/OpenCV-android-sdk/sdk/native/libs/armeabi-v7a/libopencv_video.a /home/user/Downloads/android-ndk-r16b/platforms/android-23/arch-arm/usr/lib/liblog.so ../../../../src/main/cpp/libs/libgnustl_shared.so -lncnn -lboost_filesystem-clang-mt-a32-1_66 -lboost_system-clang-mt-a32-1_66 /home/user/git/project/OpenCV-android-sdk/sdk/native/libs/armeabi-v7a/libopencv_androidcamera.a /home/user/git/project/OpenCV-android-sdk/sdk/native/3rdparty/libs/armeabi-v7a/liblibjpeg.a /home/user/git/project/OpenCV-android-sdk/sdk/native/3rdparty/libs/armeabi-v7a/liblibpng.a /home/user/git/project/OpenCV-android-sdk/sdk/native/3rdparty/libs/armeabi-v7a/liblibtiff.a /home/user/git/project/OpenCV-android-sdk/sdk/native/3rdparty/libs/armeabi-v7a/liblibjasper.a /home/user/git/project/OpenCV-android-sdk/sdk/native/3rdparty/libs/armeabi-v7a/libIlmImf.a /home/user/git/project/OpenCV-android-sdk/sdk/native/libs/armeabi-v7a/libopencv_imgproc.a /home/user/git/project/OpenCV-android-sdk/sdk/native/libs/armeabi-v7a/libopencv_core.a -lz -ldl -lm -llog -ldl -lm -llog -latomic -lm "/home/user/Downloads/android-ndk-r16b/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/libsupc++.a" "/home/user/Downloads/android-ndk-r16b/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/libgnustl_shared.so" && : ./boost/system/system_error.hpp:31: error: undefined reference to 'std::runtime_error::runtime_error(std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&)' ./boost/system/system_error.hpp:31: error: undefined reference to 'std::runtime_error::runtime_error(std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&)' /home/user/Downloads/android-ndk-r16b/sources/cxx-stl/llvm-libc++/include/stdexcept:136: error: undefined reference to 'std::logic_error::logic_error(char const*)' ./boost/system/system_error.hpp:31: error: undefined reference to 'std::runtime_error::runtime_error(std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&)' libs/filesystem/src/path.cpp:897: error: undefined reference to 'std::__ndk1::locale::locale(char const*)' /home/user/Downloads/android-ndk-r16b/sources/cxx-stl/llvm-libc++/include/__locale:212: error: undefined reference to 'std::__ndk1::locale::use_facet(std::__ndk1::locale::id&) const' libs/filesystem/src/path.cpp:914: error: undefined reference to 'std::__ndk1::locale::~locale()' libs/filesystem/src/path.cpp:914: error: undefined reference to 'std::__ndk1::codecvt<wchar_t, char, mbstate_t>::id' libs/filesystem/src/path.cpp:897: error: undefined reference to 'std::__ndk1::locale::locale(char const*)' libs/filesystem/src/path.cpp:947: error: undefined reference to 'std::__ndk1::locale::locale(std::__ndk1::locale const&)' libs/filesystem/src/path.cpp:897: error: undefined reference to 'std::__ndk1::locale::locale(char const*)' libs/filesystem/src/path.cpp:948: error: undefined reference to 'std::__ndk1::locale::operator=(std::__ndk1::locale const&)' libs/filesystem/src/path.cpp:950: error: undefined reference to 'std::__ndk1::locale::~locale()' libs/filesystem/src/path.cpp:914: error: undefined reference to 'std::__ndk1::locale::~locale()' libs/filesystem/src/path.cpp:914: error: undefined reference to 'std::__ndk1::locale::~locale()' /home/user/Downloads/android-ndk-r16b/sources/cxx-stl/llvm-libc++/include/stdexcept:146: error: undefined reference to 'std::logic_error::logic_error(char const*)' collect2: error: ld returned 1 exit status ninja: build stopped: subcommand failed. * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. * Get more help at help.gradle BUILD FAILED in 2s

我曾尝试使用-DANDROID_STL = gnu_shared或-DANDROID_STL = gnu_static并得到相同的结果.花了一天的时间,我仍然无法使其编译.

I had tried to use -DANDROID_STL=gnu_shared or -DANDROID_STL=gnu_static and got the same result. Spent a day on it, I still cannot make it compilable.

在CMakeList中:

In CMakeList:

add_library(lib_opencv SHARED IMPORTED) add_library(lib_gnustl_shared SHARED IMPORTED) set_target_properties(lib_opencv PROPERTIES IMPORTED_LOCATION ${pathToProject}/app/src/main/jniLibs/${ANDROID_ABI}/libopencv_java.so) set_target_properties(lib_gnustl_shared PROPERTIES IMPORTED_LOCATION ${pathToProject}/app/src/main/cpp/libs/libgnustl_shared.so) target_link_libraries( # Specifies the target library. native-lib lib_opencv # Links the target library to the log library # included in the NDK. ${OpenCV_LIBS} ${log-lib} boost_filesystem-clang-mt-a32-1_66 boost_system-clang-mt-a32-1_66 lib_gnustl_shared )

在gradle中:

externalNativeBuild { cmake { arguments "-DANDROID_TOOLCHAIN=gcc","-DANDROID_ARM_NEON=TRUE" ,"-DANDROID_STL_FORCE_FEATURES=OFF", "-DANDROID_STL=gnustl_shared" cppFlags "-std=c++11", "-Wno-error=format-security", "-fpermissive", "-fopenmp", "-Og" }

推荐答案

您的Boost库是使用libc ++构建的(您可以知道,因为它具有对 std :: __ ndk1 :: **的引用,而不只是对 std :: * ).您需要使用libc ++,而不是gnustl.

Your boost library was built with libc++ (you can tell because it has references to std::__ndk1::* rather than just std::*). You need to use libc++, not gnustl.

更多推荐

错误对'std ::

本文发布于:2023-11-24 16:54:04,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1626056.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:错误   std

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!