CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
Asked Answered
P

4

6

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! 
Personable answered 8/6, 2018 at 9:8 Comment(5)
did you updated the NDK?Christo
@Christo I open the sdk manager in Android studio, it only has one version 3.6.4111459. What do you say about updating the ndk?Personable
Do you have an update available for cmake? seems like an update that was borken, in my case I have /Android/Sdk/cmake/3.6.4111459/share/cmake-3.6 instead of 3.5, so if you have an update available so updated else remove it an install it again via sdk managerChristo
@Christo I delete it and install it again. Yes, I also have Android/Sdk/cmake/3.6.4111459/share/cmake-3.6, but still got the same errorPersonable
Please check my answerChristo
C
14

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'
            }
        }
    }
 ....
}
Christo answered 8/6, 2018 at 11:10 Comment(3)
After updating gradle plugin and gradle wrapper version, it works. Thanks. It seems that I do not need to add abiFilters.Personable
"externalNativeBuild" helped, while updating gradle-4.x version does not help in my case. Thanks!Marked
externalNativeBuild" helped me . Thanks a lot!!Recede
F
9

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]
            }
        }
    }
 ....
}
Figurative answered 9/10, 2018 at 10:56 Comment(0)
W
6

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

Wootten answered 26/10, 2018 at 10:5 Comment(0)
H
0

I just uninstall and reinstall the NDK from SDK tools. This works for me.

Hannigan answered 12/1 at 20:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.