The C compiler clang.exe is not able to complete a simple test program

3,235 views
Skip to first unread message

Alex David

unread,
Jun 14, 2017, 3:15:31 PM6/14/17
to android-ndk

64 bit Windows 10. Android Studio 2.3.3.

I'm trying to use JNI to link an existing C++ project to Android Studio. I've also tried to load all of the provided NDK-JNI sample projects. Everything with JNI/Cmake is unable to Gradle Sync, failing with the same error:


Build command failed.
Error while executing process C:\Users\Alex\AppData\Local\Android\Sdk\cmake\3.6.3155560\bin\cmake.exe with arguments {-HC:\Users\Alex\Desktop\android-ndk\hello-jni\app\src\main\cpp -BC:\Users\Alex\Desktop\android-ndk\hello-jni\app\.externalNativeBuild\cmake\armDebug\armeabi -GAndroid Gradle - Ninja -DANDROID_ABI=armeabi -DANDROID_NDK=C:\Users\Alex\AppData\Local\Android\Sdk\ndk-bundle -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\Users\Alex\Desktop\android-ndk\hello-jni\app\build\intermediates\cmake\arm\debug\obj\armeabi -DCMAKE_BUILD_TYPE=Debug -DCMAKE_MAKE_PROGRAM=C:\Users\Alex\AppData\Local\Android\Sdk\cmake\3.6.3155560\bin\ninja.exe -DCMAKE_TOOLCHAIN_FILE=C:\Users\Alex\AppData\Local\Android\Sdk\ndk-bundle\build\cmake\android.toolchain.cmake -DANDROID_PLATFORM=android-23 -DANDROID_TOOLCHAIN=clang}
-- Check for working C compiler: C:/Users/Alex/AppData/Local/Android/sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe
-- Check for working C compiler: C:/Users/Alex/AppData/Local/Android/sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe -- broken
CMake Error at C:/Users/Alex/AppData/Local/Android/sdk/cmake/3.6.3155560/share/cmake-3.6/Modules/CMakeTestCCompiler.cmake:61 (message):
The C compiler
"C:/Users/Alex/AppData/Local/Android/sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: C:/Users/Alex/Desktop/android-ndk/hello-jni/app/.externalNativeBuild/cmake/armDebug/armeabi/CMakeFiles/CMakeTmp
Run Build
Command:"C:\Users\Alex\AppData\Local\Android\Sdk\cmake\3.6.3155560\bin\ninja.exe"
"cmTC_accda"
[1/2] Building C object CMakeFiles/cmTC_accda.dir/testCCompiler.c.o
[2/2] Linking C executable cmTC_accda
FAILED: cmd.exe /C "cd .  &&
C:\Users\Alex\AppData\Local\Android\sdk\ndk-bundle\toolchains\llvm\prebuilt\windows-x86_64\bin\clang.exe
--target=armv5te-none-linux-androideabi
--gcc-toolchain=C:/Users/Alex/AppData/Local/Android/sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64
--sysroot=C:/Users/Alex/AppData/Local/Android/sdk/ndk-bundle/sysroot
-isystem
C:/Users/Alex/AppData/Local/Android/sdk/ndk-bundle/sysroot/usr/include/arm-linux-androideabi
-D__ANDROID_API__=23 -g -DANDROID -ffunction-sections -funwind-tables
-fstack-protector-strong -no-canonical-prefixes -march=armv5te
-Werror=format-security -Wl,--exclude-libs,libgcc.a --sysroot
C:/Users/Alex/AppData/Local/Android/sdk/ndk-bundle/platforms/android-23/arch-arm64
-Wl,--build-id -Wl,--warn-shared-textrel -Wl,--fatal-warnings
-Wl,--no-undefined -Wl,-z,noexecstack -Qunused-arguments -Wl,-z,relro
-Wl,-z,now -Wl,--gc-sections -Wl,-z,nocopyreloc -pie -fPIE
CMakeFiles/cmTC_f48b1.dir/testCCompiler.c.o -o cmTC_f48b1 -lm && cd ."
The system cannot find the path specified.
ninja: build stopped: subcommand failed.
CMake will not be able to correctly generate this project.

I have all necessary SDK tools installed. I've tried using GCC instead of clang. Thanks for your help!

Dan Albert

unread,
Jun 14, 2017, 5:10:54 PM6/14/17
to android-ndk

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-ndk+unsubscribe@googlegroups.com.
To post to this group, send email to andro...@googlegroups.com.
Visit this group at https://groups.google.com/group/android-ndk.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/2d558649-fe8f-4f56-8d3a-c5210bd460a3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Alex Cohn

unread,
Jun 15, 2017, 7:38:35 AM6/15/17
to android-ndk
First of all, check: maybe file C:\Users\Alex\AppData\Local\Android\sdk\ndk-bundle\toolchains\llvm\prebuilt\windows-x86_64\bin\clang.exe  is missing.

I notice that your Android SDK is installed at C:\Users\Alex\AppData\Local\Android\Sdk (with Captial `S`), but it's looking for compiler under C:\Users\Alex\AppData\Local\Android\sdk (with small `s`). I have no idea how this can be relevant on Windows, but I would give this hypothesis a try.

Another option could be that you installed NDK not in the default location, or maybe you installed NDK for different architecture (you need android-ndk-r15-windows-x86_64.zip).

BR,
Alex Cohn

Wang Bin

unread,
Jul 5, 2017, 10:01:44 AM7/5/17
to android-ndk
The dir windows-x86_64 becomes windows since r14b, so cmake can not find the compiler

Andrew Esh

unread,
Jul 6, 2017, 1:18:47 PM7/6/17
to android-ndk

To deal with problems like this, take apart the config.log file. Find the exact point where the same error message was printed. It's usually a few pages up from the bottom of the file. 

Just above the error message, you will find a listing of conftest.c. Copy that and paste it into a C text file, and strip out the leading "log" characters from each line.

Above the program listing, there is a complete command line for the command that failed. Copy that and paste all of it except the I/O redirect part at the end (beginning with ">").
When you run the command, it should produce the exact same error. You can tweak the command until you discover what's missing or wrong. Then you have an idea what needs
to be done to configure.ac to solve the problem.
Reply all
Reply to author
Forward
0 new messages