Ubuntu 18.04: No CMAKE_C_COMPILER could be found

Viewed 18936

I am trying to install gtest from Google but even though I have gcc and g++ installed, I get this error for some reason. I am on Ubuntu 18.04 64 bit. And I don't have anything to do with Visual Studio stuff.

-- The C compiler identification is unknown
CMake Error at CMakeLists.txt:47 (project):
  No CMAKE_C_COMPILER could be found.

  Tell CMake where to find the compiler by setting either the environment
  variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to
  the compiler, or to the compiler name if it is in the PATH.


-- Configuring incomplete, errors occurred!
See also "/usr/src/googletest/googletest/CMakeFiles/CMakeOutput.log".
See also "/usr/src/googletest/googletest/CMakeFiles/CMakeError.log".

This is there:

$ gcc --version
gcc (GCC) 6.4.0

$ g++ --version 
g++ (GCC) 6.4.0

and this:

user@user:/usr/src/gtest$ whereis g++
g++: /usr/bin/g++ /usr/share/man/man1/g++.1.gz
user@user:/usr/src/gtest$ whereis gcc
gcc: /usr/bin/gcc /usr/lib/gcc /usr/local/cuda-9.0/bin/gcc /usr/share/man/man1/gcc.1.gz

also:

user@user:/usr/src/gtest$ ls -la /usr/bin | grep gcc-6.4
lrwxrwxrwx  1 root root          16 Nov 12 14:47 gcc -> /usr/bin/gcc-6.4


user@user:/usr/src/gtest$ ls -la /usr/bin | grep g++-6
lrwxrwxrwx  1 root root          14 Nov 12 14:51 g++ -> /usr/bin/g++-6
lrwxrwxrwx  1 root root          22 Apr 24  2018 g++-6 -> x86_64-linux-gnu-g++-6
-rwxr-xr-x  1 root root      953176 Apr 24  2018 x86_64-linux-gnu-g++-6

Given all this, does anyone have a clue?

Thanks in advance.

UPDATE: This seems to have worked:

Okay, this seems to be working:

cmake -D CMAKE_C_COMPILER="/usr/local/cuda-9.0/bin/gcc " -D CMAKE_CXX_COMPILER="/usr/bin/g++" /usr/src/gtest/CMakeLists.txt

which apparently points to the gcc used cuda. Is there a way of setting the one under /usr/bin/ as the default one?

0 Answers
Related