gcc - 如何在 Android 上使用带有 gcc 的 NDK?
问题描述
我需要编译 OpenCV 2 来测试一些东西,它只能用 gcc 构建。我尝试在 Android Studio 中下载最旧的 NDK 版本 16,但它仍然尝试使用 clang。如何强制它使用 gcc?
版本 16 上的错误:
ERROR: /home/user/AndroidStudioProjects/opencv2builder/app/src/main/cpp/CMakeLists.txt : C/C++ debug|x86 : CMake Error at /home/user/Android/Sdk/cmake/3.10.2.4988404/share/cmake-3.10/Modules/CMakeTestCCompiler.cmake:52 (message):
The C compiler
"/home/user/Android/Sdk/ndk/16.1.4479499/toolchains/llvm/prebuilt/linux-x86_64/bin/clang"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: /home/user/AndroidStudioProjects/opencv2builder/app/.cxx/cmake/debug/x86/CMakeFiles/CMakeTmp
Run Build Command:"/home/user/Android/Sdk/cmake/3.10.2.4988404/bin/ninja" "cmTC_ed369"
[1/2] Building C object CMakeFiles/cmTC_ed369.dir/testCCompiler.c.o
FAILED: CMakeFiles/cmTC_ed369.dir/testCCompiler.c.o
/home/user/Android/Sdk/ndk/16.1.4479499/toolchains/llvm/prebuilt/linux-x86_64/bin/clang --target=i686-none-linux-android --gcc-toolchain=/home/user/Android/Sdk/ndk/16.1.4479499/toolchains/x86-4.9/prebuilt/linux-x86_64 --sysroot=/home/user/Android/Sdk/ndk/16.1.4479499/sysroot -isystem /home/user/Android/Sdk/ndk/16.1.4479499/sysroot/usr/include/i686-linux-android -D__ANDROID_API__=16 -g -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -mstackrealign -Wa,--noexecstack -Wformat -Werror=format-security -fPIE -o CMakeFiles/cmTC_ed369.dir/testCCompiler.c.o -c testCCompiler.c
/home/user/Android/Sdk/ndk/16.1.4479499/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
Affected Modules: app
解决方案
推荐阅读
- c++ - 与多个 for 循环相关的性能与从 multimap 获取数据的单个 for 循环相关的性能
- javascript - 无法在 Audio.playnxt 读取未定义的属性“NaN”
- c++ - 接收和返回函数指针的函数指针类型?
- javascript - 遍历对象数组中的每个元素
- python - 如何评估具有给定(=未优化)系数的统计模型?
- python - 如何编写 key(get,default) 方法?
- java - Why doesn't java.lang.Enum::valueOf check for the null name first?
- c++ - 继承模板化转换运算符
- elasticsearch - Elasticsearch - 根据另一个字段上没有值来查找字段的值
- java - 无法将我的 java 应用程序连接到 Elastic Stack 实例