我正在尝试从Google安装gtest,但是即使我已经安装了gcc和g ++,由于某种原因,我也会收到此错误。我使用的是Ubuntu 18.04 64位。而且我与Visual Studio无关。
-- 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".
这里有:
$ gcc --version
gcc (GCC) 6.4.0
$ g++ --version
g++ (GCC) 6.4.0
这:
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
还:
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
鉴于所有这些,有人知道吗?
谢谢。
更新:这似乎有效:
好的,这似乎可行:
cmake -D CMAKE_C_COMPILER="/usr/local/cuda-9.0/bin/gcc " -D CMAKE_CXX_COMPILER="/usr/bin/g++" /usr/src/gtest/CMakeLists.txt
显然指向gcc使用的cuda。有没有一种方法可以将/ usr / bin /下的设置为默认设置?