I use wsl with Ubuntu 18.04. I upgraded my GCC from version 7 to version 9.2 and now I can no longer compile my project. I have this error message. I also upgraded my cmake version from 3.10 to 3.16.4
cmake -G"Unix Makefiles" ./.. && make && ./tests/unit_tests/UnitTests.out
-- The CXX compiler identification is unknown
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- broken
CMake Error at /home/matthieu/cmake-3.16.4-Linux-x86_64/share/cmake-3.16/Modules/CMakeTestCXXCompiler.cmake:53 (message):
The C++ compiler
"/usr/bin/c++"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: /home/matthieu/StraightforwardNeuralNetwork/build/CMakeFiles/CMakeTmp
Run Build Command(s):/usr/bin/make cmTC_990de/fast && /usr/bin/make -f CMakeFiles/cmTC_990de.dir/build.make CMakeFiles/cmTC_990de.dir/build
make[1]: Entering directory '/mnt/c/programming/GitHub/StraightforwardNeuralNetwork/build/CMakeFiles/CMakeTmp'
Building CXX object CMakeFiles/cmTC_990de.dir/testCXXCompiler.cxx.o
/usr/bin/c++ -o CMakeFiles/cmTC_990de.dir/testCXXCompiler.cxx.o -c /home/matthieu/StraightforwardNeuralNetwork/build/CMakeFiles/CMakeTmp/testCXXCompiler.cxx
c++: fatal error: ‘-c’ is not a valid option to the preprocessor
compilation terminated.
CMakeFiles/cmTC_990de.dir/build.make:65: recipe for target 'CMakeFiles/cmTC_990de.dir/testCXXCompiler.cxx.o' failed
make[1]: *** [CMakeFiles/cmTC_990de.dir/testCXXCompiler.cxx.o] Error 1
make[1]: Leaving directory '/mnt/c/programming/GitHub/StraightforwardNeuralNetwork/build/CMakeFiles/CMakeTmp'
Makefile:121: recipe for target 'cmTC_990de/fast' failed
make: *** [cmTC_990de/fast] Error 2
This is very strange because my version of GCC looks good.
matthieu@DESKTOP-PC05NH3:~$ gcc --version
gcc (Ubuntu 9.2.1-17ubuntu1~18.04.1) 9.2.1 20191102
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Same for g++ --version
, c++ --version
and cpp --version
.
For install GCC 9.2
I install gcc-9
and bind to gcc
with sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 60
Same for g++
, c++
and cpp
.
Maybe the error comes from there.
Can you help me please ?