错误对'std :: __ ndk1 :: locale ::〜locale()的未定义引用 [英] Error Undefined reference to 'std::__ndk1::locale::~locale()'

查看:342
本文介绍了错误对'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 https://help.gradle.org

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 :: __ ndk1 :: locale ::〜locale()的未定义引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆