IncludeC++Support项目直接报错

最近在把开发环境往Linux上整,有些操作比较方便,但是我发现我在Androidstudio创建项目时如果把Include C++ Support选项勾上的话,创建出来的项目直接就是错的,百度了半天也没解决,ndk卸载安装好几次了,也试了ndk-r12,ndk-r13,还是不行,求帮助啊,折腾的不要不要的。错误如下:

External Native Build Issues
Build command failed.
Error while executing process /home/majes/Android/Sdk/cmake/3.6.4111459/bin/cmake with arguments {-H/home/majes/AndroidStudioProjects/MyApplication2/app -B/home/majes/AndroidStudioProjects/MyApplication2/app/.externalNativeBuild/cmake/release/armeabi -DANDROID_ABI=armeabi -DANDROID_PLATFORM=android-15 -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/home/majes/AndroidStudioProjects/MyApplication2/app/build/intermediates/cmake/release/obj/armeabi -DCMAKE_BUILD_TYPE=Release -DANDROID_NDK=/home/majes/Android/Sdk/ndk-bundle -DCMAKE_CXX_FLAGS= -DCMAKE_TOOLCHAIN_FILE=/home/majes/Android/Sdk/ndk-bundle/build/cmake/android.toolchain.cmake -DCMAKE_MAKE_PROGRAM=/home/majes/Android/Sdk/cmake/3.6.4111459/bin/ninja -GAndroid Gradle - Ninja}
-- Check for working C compiler: /home/majes/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/clang
-- Check for working C compiler: /home/majes/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/clang -- broken
It fails with the following output:
Change Dir: /home/majes/AndroidStudioProjects/MyApplication2/app/.externalNativeBuild/cmake/release/armeabi/CMakeFiles/CMakeTmp
Run Build Command:"/home/majes/Android/Sdk/cmake/3.6.4111459/bin/ninja"
"cmTC_af686"
[1/2] Building C object CMakeFiles/cmTC_af686.dir/testCCompiler.c.o
FAILED:
/home/majes/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/clang
--target=armv5te-none-linux-androideabi
--gcc-toolchain=/home/majes/Android/Sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64
--sysroot=/home/majes/Android/Sdk/ndk-bundle/sysroot -isystem
/home/majes/Android/Sdk/ndk-bundle/sysroot/usr/include/arm-linux-androideabi
-D__ANDROID_API__=15 -g -DANDROID -ffunction-sections -funwind-tables
-fstack-protector-strong -no-canonical-prefixes -march=armv5te
-mtune=xscale -msoft-float -fno-integrated-as -mthumb -Wa,--noexecstack
-Wformat -Werror=format-security -o
CMakeFiles/cmTC_af686.dir/testCCompiler.c.o -c
/home/majes/AndroidStudioProjects/MyApplication2/app/.externalNativeBuild/cmake/release/armeabi/CMakeFiles/CMakeTmp/testCCompiler.c
/home/majes/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/clang:
error while loading shared libraries: libncurses.so.5: cannot open shared
object file: No such file or directory
ninja: build stopped: subcommand failed.
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt
-- Configuring incomplete, errors occurred!
See also "/home/majes/AndroidStudioProjects/MyApplication2/app/.externalNativeBuild/cmake/release/armeabi/CMakeFiles/CMakeOutput.log".
See also "/home/majes/AndroidStudioProjects/MyApplication2/app/.externalNativeBuild/cmake/release/armeabi/CMakeFiles/CMakeError.log".
Build command failed.
Error while executing process /home/majes/Android/Sdk/cmake/3.6.4111459/bin/cmake with arguments {-H/home/majes/AndroidStudioProjects/MyApplication2/app -B/home/majes/AndroidStudioProjects/MyApplication2/app/.externalNativeBuild/cmake/debug/armeabi -DANDROID_ABI=armeabi -DANDROID_PLATFORM=android-15 -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/home/majes/AndroidStudioProjects/MyApplication2/app/build/intermediates/cmake/debug/obj/armeabi -DCMAKE_BUILD_TYPE=Debug -DANDROID_NDK=/home/majes/Android/Sdk/ndk-bundle -DCMAKE_CXX_FLAGS= -DCMAKE_TOOLCHAIN_FILE=/home/majes/Android/Sdk/ndk-bundle/build/cmake/android.toolchain.cmake -DCMAKE_MAKE_PROGRAM=/home/majes/Android/Sdk/cmake/3.6.4111459/bin/ninja -GAndroid Gradle - Ninja}
-- Check for working C compiler: /home/majes/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/clang
-- Check for working C compiler: /home/majes/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/clang -- broken
It fails with the following output:
Change Dir: /home/majes/AndroidStudioProjects/MyApplication2/app/.externalNativeBuild/cmake/debug/armeabi/CMakeFiles/CMakeTmp
Run Build Command:"/home/majes/Android/Sdk/cmake/3.6.4111459/bin/ninja"
"cmTC_2e591"
[1/2] Building C object CMakeFiles/cmTC_2e591.dir/testCCompiler.c.o
FAILED:
/home/majes/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/clang
--target=armv5te-none-linux-androideabi
--gcc-toolchain=/home/majes/Android/Sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64
--sysroot=/home/majes/Android/Sdk/ndk-bundle/sysroot -isystem
/home/majes/Android/Sdk/ndk-bundle/sysroot/usr/include/arm-linux-androideabi
-D__ANDROID_API__=15 -g -DANDROID -ffunction-sections -funwind-tables
-fstack-protector-strong -no-canonical-prefixes -march=armv5te
-mtune=xscale -msoft-float -fno-integrated-as -mthumb -Wa,--noexecstack
-Wformat -Werror=format-security -o
CMakeFiles/cmTC_2e591.dir/testCCompiler.c.o -c
/home/majes/AndroidStudioProjects/MyApplication2/app/.externalNativeBuild/cmake/debug/armeabi/CMakeFiles/CMakeTmp/testCCompiler.c
/home/majes/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/clang:
error while loading shared libraries: libncurses.so.5: cannot open shared
object file: No such file or directory
ninja: build stopped: subcommand failed.
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt
-- Configuring incomplete, errors occurred!
See also "/home/majes/AndroidStudioProjects/MyApplication2/app/.externalNativeBuild/cmake/debug/armeabi/CMakeFiles/CMakeOutput.log".
See also "/home/majes/AndroidStudioProjects/MyApplication2/app/.externalNativeBuild/cmake/debug/armeabi/CMakeFiles/CMakeError.log".
/home/majes/Android/Sdk/cmake/3.6.4111459/share/cmake-3.6/Modules/CMakeTestCCompiler.cmake

Error:(61, 0) The C compiler "/home/majes/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/clang" is not able to compile a simple test program.

Error:(61, 0) The C compiler "/home/majes/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/clang" is not able to compile a simple test program.

2个回答

用Linux玩as需要修改环境变量的,不知道你改了没,看你的报错很有可能没改,可以去搜一下Linux装as教程,里面会教怎么改环境变量。

Forsaken0506
Sino_MaJes 环境变量基本不需要改什么,就是个jdk,arch和ubuntu,fedora,依赖不一样,,androidstudio官网只说了ubuntu,fedora的依赖包,不过还是谢谢你的提醒,我是照着arch wiki弄好了。
接近 2 年之前 回复
Forsaken0506
Sino_MaJes cmake,lldb,ndk都有,是项目一创建出来就直接是错的了
接近 2 年之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!