When I build an android project which includes ndk code. I got the following error:
Build command failed.
Error while executing process /home/gongzelong/Android/Sdk/cmake/3.6.4111459/bin/cmake with arguments {-H/media/gongzelong/TOSHIBA/Code/Code/ImageLoaderEncapsulation/ImageLoader/ImageLoaderDemo/app -B/media/gongzelong/TOSHIBA/Code/Code/ImageLoaderEncapsulation/ImageLoader/ImageLoaderDemo/app/.externalNativeBuild/cmake/debug/armeabi -GAndroid Gradle - Ninja -DANDROID_ABI=armeabi -DANDROID_NDK=/home/gongzelong/Android/Sdk/ndk-bundle -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/media/gongzelong/TOSHIBA/Code/Code/ImageLoaderEncapsulation/ImageLoader/ImageLoaderDemo/app/build/intermediates/cmake/debug/obj/armeabi -DCMAKE_BUILD_TYPE=Debug -DCMAKE_MAKE_PROGRAM=/home/gongzelong/Android/Sdk/cmake/3.6.4111459/bin/ninja -DCMAKE_TOOLCHAIN_FILE=/home/gongzelong/Android/Sdk/ndk-bundle/build/cmake/android.toolchain.cmake -DANDROID_PLATFORM=android-14 -DCMAKE_CXX_FLAGS=}
/media/gongzelong/TOSHIBA/Code/Code/ImageLoaderEncapsulation/ImageLoader/ImageLoaderDemo
CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!
Build command failed.
Error while executing process /home/gongzelong/Android/Sdk/cmake/3.6.4111459/bin/cmake with arguments {-H/media/gongzelong/TOSHIBA/Code/Code/ImageLoaderEncapsulation/ImageLoader/ImageLoaderDemo/app -B/media/gongzelong/TOSHIBA/Code/Code/ImageLoaderEncapsulation/ImageLoader/ImageLoaderDemo/app/.externalNativeBuild/cmake/release/armeabi -GAndroid Gradle - Ninja -DANDROID_ABI=armeabi -DANDROID_NDK=/home/gongzelong/Android/Sdk/ndk-bundle -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/media/gongzelong/TOSHIBA/Code/Code/ImageLoaderEncapsulation/ImageLoader/ImageLoaderDemo/app/build/intermediates/cmake/release/obj/armeabi -DCMAKE_BUILD_TYPE=Release -DCMAKE_MAKE_PROGRAM=/home/gongzelong/Android/Sdk/cmake/3.6.4111459/bin/ninja -DCMAKE_TOOLCHAIN_FILE=/home/gongzelong/Android/Sdk/ndk-bundle/build/cmake/android.toolchain.cmake -DANDROID_PLATFORM=android-14 -DCMAKE_CXX_FLAGS=}
CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!
I try to locate the cause.
I found the following:
gongzelong@gongzelong:~/Android/Sdk/cmake/3.6.4111459/bin$ cmake -version
CMake Error: Could not find CMAKE_ROOT !!!
CMake has most likely not been installed correctly.
Modules directory not found in
/home/gongzelong/Android/Sdk/cmake/3.6.4111459/share/cmake-3.5
cmake version 3.5.1
CMake suite maintained and supported by Kitware (kitware.com/cmake).
It seems that the cmake has separately versions 3.5 and 3.6.
Could anyone point out how to fix it and build the android project successfully?
Update:
I delete the cmake and install it again in android studio sdk manager.
I still got this:
null
Build command failed.
Error while executing process /home/gongzelong/Android/Sdk/cmake/3.6.4111459/bin/cmake with arguments {-H/media/gongzelong/TOSHIBA/Code/Code/ImageLoaderEncapsulation/ImageLoader/ImageLoaderDemo/app -B/media/gongzelong/TOSHIBA/Code/Code/ImageLoaderEncapsulation/ImageLoader/ImageLoaderDemo/app/.externalNativeBuild/cmake/debug/armeabi -GAndroid Gradle - Ninja -DANDROID_ABI=armeabi -DANDROID_NDK=/home/gongzelong/Android/Sdk/ndk-bundle -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/media/gongzelong/TOSHIBA/Code/Code/ImageLoaderEncapsulation/ImageLoader/ImageLoaderDemo/app/build/intermediates/cmake/debug/obj/armeabi -DCMAKE_BUILD_TYPE=Debug -DCMAKE_MAKE_PROGRAM=/home/gongzelong/Android/Sdk/cmake/3.6.4111459/bin/ninja -DCMAKE_TOOLCHAIN_FILE=/home/gongzelong/Android/Sdk/ndk-bundle/build/cmake/android.toolchain.cmake -DANDROID_PLATFORM=android-14 -DCMAKE_CXX_FLAGS=}
/media/gongzelong/TOSHIBA/Code/Code/ImageLoaderEncapsulation/ImageLoader/ImageLoaderDemo
CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!
Build command failed.
Error while executing process /home/gongzelong/Android/Sdk/cmake/3.6.4111459/bin/cmake with arguments {-H/media/gongzelong/TOSHIBA/Code/Code/ImageLoaderEncapsulation/ImageLoader/ImageLoaderDemo/app -B/media/gongzelong/TOSHIBA/Code/Code/ImageLoaderEncapsulation/ImageLoader/ImageLoaderDemo/app/.externalNativeBuild/cmake/release/armeabi -GAndroid Gradle - Ninja -DANDROID_ABI=armeabi -DANDROID_NDK=/home/gongzelong/Android/Sdk/ndk-bundle -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/media/gongzelong/TOSHIBA/Code/Code/ImageLoaderEncapsulation/ImageLoader/ImageLoaderDemo/app/build/intermediates/cmake/release/obj/armeabi -DCMAKE_BUILD_TYPE=Release -DCMAKE_MAKE_PROGRAM=/home/gongzelong/Android/Sdk/cmake/3.6.4111459/bin/ninja -DCMAKE_TOOLCHAIN_FILE=/home/gongzelong/Android/Sdk/ndk-bundle/build/cmake/android.toolchain.cmake -DANDROID_PLATFORM=android-14 -DCMAKE_CXX_FLAGS=}
CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!
CMakeLists. txt file contains a set of directives and instructions describing the project's source files and targets (executable, library, or both). When you create a new project, CLion generates CMakeLists. txt file automatically and places it in the project root directory.
CXX the C++ Compiler - the program understanding the C++ language, taking a .cc/.cpp source code file and generating a .o object file out of it. LD the linker - the program taking multiple .o files and libraries .so/.a (e.g. libboost) and generating an executable ELF file out of it - the final binary.
It seems like you are using an NDK version that is no more supporting some ABIs (armeabi in you error log), so you have to upgrade build in build.gradle (Project:....) to the latest one
classpath 'com.android.tools.build:gradle:3.1.3'
And in gradle-wraper.properties : distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
And finally, you have to add abiFilters in android block of your build.gradle(Module:app) depending of wich ABIs you need:
android {
....
defaultConfig {
externalNativeBuild {
cmake {
abiFilters 'arm64-v8a', 'armeabi-v7a', 'x86', 'x86_64'
}
}
}
....
}
In my case, following changes in build.gradle (Module:app ) help me.
Original
android {
....
defaultConfig {
externalNativeBuild {
cmake {
arguments '-DANDROID_STL=gnustl_static' ... [other args]
}
}
}
....
}
With my changes
android {
android.buildToolsVersion "28.0.3"
....
defaultConfig {
externalNativeBuild {
cmake {
'-DANDROID_STL=c++_static' ... [other args]
}
}
}
....
}
I have the same error, and my ndk-bundle is the newest, which is ndk-r18b
CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage Configuring incomplete, errors occurred!
I fix it by use android-ndk-r14b, you can specify it in local.properties
ndk.dir=/Users/xxxx/Library/Android/sdk/android-ndk-r14b
Of course, you should download r14b first, and unzip it under the sdk folder
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With