Cmake cannot find the gcc/g++ compilers
Hi, I installed build essentials, gcc, g++, cmake, make and I tried to run a simple project. However I get error messages from CMAKE that the compiler is broken.
:/mnt/c/Users/NAME/Documents/githubLocal/mybuild$ cmake Unix Makefiles -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_COMPILER=/usr/bin/g++ - DCMAKE_CC_COMPILER=/usr/bin/gcc .. -- The C compiler identification is unknown CMake Error at /usr/share/cmake-2.8/Modules/CMakeDetermineCCompiler.cmake:186 (configure_file): configure_file Problem configuring file Call Stack (most recent call first): CMakeLists.txt:59 (project)
-- The CXX compiler identification is unknown
CMake Error at /usr/share/cmake-2.8/Modules/CMakeDetermineCXXCompiler.cmake:185 (configure_file):
configure_file Problem configuring file Call Stack (most recent call first): CMakeLists.txt:59 (project)
-- Check for working C compiler: /usr/bin/cc CMake Error at /usr/share/cmake-2.8/Modules/CMakeTestCCompiler.cmake:47 (try_compile): Unknown extension ".c" for file
/mnt/c/Users/NAME/Documents/githubLocal/mybuild/CMakeFiles/CMakeTmp/testCCompiler.c
try_compile() works only for enabled languages. Currently these are:
C CXX
See project() command to enable other languages. Call Stack (most recent call first): CMakeLists.txt:59 (project)
-- Check for working C compiler: /usr/bin/cc -- broken CMake Error at /usr/share/cmake-2.8/Modules/CMakeTestCCompiler.cmake:61 (message): The C compiler "/usr/bin/cc" is not able to compile a simple test program.
It fails with the following output:
CMake will not be able to correctly generate this project. Call Stack (most recent call first): CMakeLists.txt:59 (project)
-- Configuring incomplete, errors occurred! See also "/mnt/c/Users/NAME/Documents/githubLocal/mybuild/CMakeFiles/CMakeOutput.log". See also "/mnt/c/Users/NAME/Documents/githubLocal/mybuild/CMakeFiles/CMakeError.log". nlappas@NIKOS-SURFACE:/mnt/c/Users/Nikos/Documents/githubLoca/mybuild$`
By the way the compilers work properly, when I use them from the command line, they compile source files and link them succesfully. Which gcc and which g++ give me also the correct paths.
Could you try cloning your git repro into your UNIX user's home directory (cd ~) and try building again?
If this is a public GitHub repro? If so send me the link and I can try this myself.
Thanks!
I tried a minimal helloworld c++ test program with the corresponding cmakefile that fails for me even in the home directory. https://github.com/nlappas/CMAKE_BASH_WINDOWS_TEST.git
Same problem here. I wanted to compile x265 (https://bitbucket.org/multicoreware/x265) and it showed:
-- The C compiler identification is unknown CMake Error at /usr/share/cmake-2.8/Modules/CMakeDetermineCCompiler.cmake:186 (configure_file): configure_file Problem configuring file Call Stack (most recent call first): CMakeLists.txt:19 (project)
-- The CXX compiler identification is unknown CMake Error at /usr/share/cmake-2.8/Modules/CMakeDetermineCXXCompiler.cmake:185 (configure_file): configure_file Problem configuring file Call Stack (most recent call first): CMakeLists.txt:19 (project)
-- Check for working C compiler: /usr/bin/cc CMake Error at /usr/share/cmake-2.8/Modules/CMakeTestCCompiler.cmake:47 (try_compile): Unknown extension ".c" for file
/root/Dev/x86_64/x265/build/linux/CMakeFiles/CMakeTmp/testCCompiler.c ...
CMakeError.log:
Compiling the C compiler identification source file "CMakeCCompilerId.c" failed. Compiler: /usr/bin/cc Build flags: Id flags:
The output was: 1 /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crt1.o: in function
_start' (.text+0x20): undefined reference tomain' collect2: error: ld returned 1 exit statusThe C compiler identification could not be found in "/root/Dev/x86_64/x265/build/linux/CMakeFiles/2.8.12.2/CompilerIdC/CMakeCCompilerId.o" ...
Currently using Insider Preview 14332. There were no problem on 14295. Didn't test on 14318.
This appears to be caused by the writev system call failing with -EFAULT on WSL and succeeding on linux when passed a struct iovec containing a null pointer.
This program prints nothing on Linux and "bad address" on WSL.
#include <sys/uio.h>
#include <iostream>
// gcc -std=c++11 main.cpp -lstdc++ && ./a.out
int main()
{
iovec iov{nullptr,0};
if( writev(1, &iov, 1) < 0)
perror(NULL);
return 0;
}
@Mcgoo Thanks for the awesome debugging! Minor note: Its actually the buffer size of zero that makes the above example work. If you change the size to non zero you will get EFAULT.
I'm actually working on a fix for this right now. I'll be sure to try cmake to make sure it works with my change.
@benhillis Yeah, seems like it shouldn't validate the pointer member if the length is zero. I'd expect EFAULT with a null pointer and a non-zero length.
Thanks, WSL is great stuff.
@mcgoo after fixing the issue with the writev system call that you identified I'm able to build run cmake on the project that @nlappas linked.
@mxalbert1996 I'm trying out https://bitbucket.org/multicoreware/x265 now.
root@BENHILL-VM7:~/CMAKE_BASH_WINDOWS_TEST# cmake .
-- The C compiler identification is GNU 4.8.4
-- The CXX compiler identification is GNU 4.8.4
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Configuring done
-- Generating done
-- Build files have been written to: /root/CMAKE_BASH_WINDOWS_TEST
@mxalbert1996 Looks like cmake is finding the C and C++ compilers, but I'm not sure what to do at this screen. If I press 'c' I get an "Errors occurred during the last pass" error.

I'm afraid I don't know what to say on that latest issue but I did get the same cmake compiler errors on both wangle (https://github.com/facebook/wangle) and casablanca (https://github.com/Microsoft/cpprestsdk) if you're looking for other projects to try it out on.
@benhillis maybe try
cd ~/x265; mkdir tmp; cd tmp; cmake ../source
and you should be able to see what cmake is complaining about.
Hello @benhillis ! I am trying to setup torch7 on my BashOnWindows and I'm getting exactly same error as described in this topic:
CMake Error at /usr/share/cmake-2.8/Modules/CMakeTestCCompiler.cmake:47 (try_compile): Unknown extension ".c" for file
/home/white/torch/build/CMakeFiles/CMakeTmp/testCCompiler.ctry_compile() works only for enabled languages. Currently these are:
C CXX
My cmake version is 2.8.12.2
I've installed Bash on my Windows 10 (build 14332) like 40 minutes ago, so i guess it's the newest version of it. If this error is already fixed, please tell me how can I get this fix. I'm very glad that here I can get support from a direct developer and I am really hoping for your feedback!
@WhiteBearSpirit Unfortunately you'll have to wait for another external release to the fast ring for this to be fixed. The change that fixes this was made a few days ago on our development branch and will take some time to reach the fast ring. Unfortunately there is currently no workaround.
Keep an eye out for our release notes as we release new builds.
Thanks @benhillis !
Bug also filed over here on the CMake tracker - https://cmake.org/Bug/view.php?id=16079.
Will point them this way as the source of the fix.
Hi @WhiteBearSpirit , if you can install Torch7 on this great Windows Bash (after they fixed the bug), please let me know... I also want to install Torch7 on Windows. Thanks!!
Adding a link to #238 since this has the same root cause.
I just updated - looks like this fix did not make it in time for 14342.
@mcgoo thanks for confirming, I will make sure that our release notes for 14342 get published today.
If you want another public repo that is affected by this, try https://github.com/julialang/julia. That might actually generally be a good test case, it compiles a LOT of external dependencies etc., so it might be a good test case.
What build number (and later) is this fixed in?