clang++.exe: error: linker command failed with exit code 1 错误解决方法

clang++.exe: error: linker command failed with exit code 1 错误解决方法

错误信息如下:

Build command failed.
Error while executing process D:\sdk\cmake\3.6.4111459\bin\cmake.exe with arguments {--build D:\master\app\.externalNativeBuild\cmake\debug\armeabi-v7a --target qg}
[1/1] Linking CXX shared library ..\..\..\..\build\intermediates\cmake\debug\obj\armeabi-v7a\libqg.so
FAILED: cmd.exe /C "cd . && D:\sdk\ndk-bundle\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++.exe  --target=armv7-none-linux-androideabi19 --gcc-toolchain=D:/sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64 --sysroot=D:/sdk/ndk-bundle/sysroot -fPIC -isystem D:/sdk/ndk-bundle/sysroot/usr/include/arm-linux-androideabi -g -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb -Wa,--noexecstack -Wformat -Werror=format-security -std=c++11 -std=c++11 -O0 -fno-limit-debug-info  -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libatomic.a -nostdlib++ --sysroot D:/sdk/ndk-bundle/platforms/android-19/arch-arm -Wl,--build-id -Wl,--warn-shared-textrel -Wl,--fatal-warnings -Wl,--fix-cortex-a8 -Wl,--exclude-libs,libunwind.a -LD:/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a -Wl,--no-undefined -Wl,-z,noexecstack -Qunused-arguments -Wl,-z,relro 
省略一万字
"D:/sdk/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/libgnustl_static.a" && cd ."
D:/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include/stdexcept:136: error: undefined reference to 'std::logic_error::logic_error(char const*)'
D:/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include/stdexcept:136: error: undefined reference to 'std::logic_error::logic_error(char const*)'
D:/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include/stdexcept:146: error: undefined reference to 'std::logic_error::logic_error(char const*)'
D:/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include/stdexcept:136: error: undefined reference to 'std::logic_error::logic_error(char const*)'
clang++.exe: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.

解决方法:

  1. 一般是ndk版本问题,用SDK Manager去下载后,仍然失败,下载的版本是18

    No toolchains found in the NDK toolchains folder for ABI with prefix: mips64el-linux-android

  2. 从官网下载ndk版本 android-ndk-r16b-windows-x86_64.zip
    下载地址:https://developer.android.com/ndk/downloads/?hl=zh-cn

  3. 替换原来sdk目录下的android-ndk

注意:用哪个版本的ndk还是看具体项目工程。

你可能感兴趣的:(android开发)