随笔 - 632  文章 - 17  评论 - 54  阅读 - 93万

ndk+cmake编译出现xxxx.app.main | debug | armeabi-v7a Compiler exited with error code 1:

一、概述

   问题现象:

    在做NDK开发时,项目能正常运行。kotlin/java端不报错。ndk端(cpp)会出现找不到系统头文件的情况。如:<jni.h>文件都找不到。但是此时项目运行起来是一点问题没有。

    此时的在ndk的cpp文件夹下写代码是没有智能提示的,那效率是相当的低,果断不能。

    使用cmake的同步功能报错如下:

复制代码
xxxx.app.main | debug | armeabi-v7a 
Compiler exited with error code 1:
 D:\ndk\android-ndk-r16\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++.exe
 -xc++ --target=armv7-none-linux-androideabi 
 --gcc-toolchain=D:/ndk/android-ndk-r16/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64 
 --sysroot=D:/ndk/android-ndk-r16/sysroot -DJCMPlayer_EXPORTS 
 -isystem D:/ndk/android-ndk-r16/sources/cxx-stl/llvm-libc++/include 
 -isystem D:/ndk/android-ndk-r16/sources/android/support/include 
 -isystem D:/ndk/android-ndk-r16/sources/cxx-stl/llvm-libc++abi/include 
 -isystem D:/ndk/android-ndk-r16/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 -fno-integrated-as -mthumb -Wa,
 --noexecstack -Wformat -std=c++11 -frtti -fexceptions -std=c++11 -O0 -fno-limit-debug-info 
 -fPIC E:\tony\demo\opengl\xxxx\app\src\main\cpp\CCOpenGLShader.cpp 
 -fpch-preprocess -v -dD -E Android clang version 5.0.300080 (based on LLVM 5.0.300080) 
 Target: armv7-none-linux-android Thread model: posix InstalledDir: 
复制代码

  

二、解决办法

  问题原因:排查到最后发现是cmake的版本不对。cmake版本太低导致的。

  1.原始环境如下:

as:AndroidStudio Giraffe 2022.3.1 Patch2
ndk:ndk-r16
gradle:7.2
cmake:3.10.2

  2.更改后的环境

as:AndroidStudio Giraffe 2022.3.1 Patch2
ndk:ndk-r16
gradle:7.2
cmake:3.18.1 (把cmake改成了本机最新版本)

   3.更细cmake环境

问题1:cmake版本过低
    CMake 3.12 or higher is required. You are running version 3.10.2
问题2:使用的cmake版本没有在sdk中,下载下就行了
    [CXX1300] CMake '3.18.2' was not found in SDK, PATH, or by cmake.dir property.

 

 

posted on   飘杨......  阅读(80)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· 单线程的Redis速度为什么快?
· 展开说说关于C#中ORM框架的用法!
· Pantheons:用 TypeScript 打造主流大模型对话的一站式集成库
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示