我经常遇到这个问题:
[idf@localhost EasyCL]$ mkdir build
[idf@localhost EasyCL]$ cd build/
[idf@localhost build]$ cmake ..
-- The C compiler identification is unknown
-- The CXX compiler identification is GNU 7.2.1
-- Check for working C compiler: /usr/bin/g++
-- Check for working C compiler: /usr/bin/g++ -- broken
CMake Error at /usr/share/cmake/Modules/CMakeTestCCompiler.cmake:51 (message):
The C compiler "/usr/bin/g++" is not able to compile a simple test program.
It fails with the following output:
Change Dir: /home/idf/Documents/opencl/EasyCL/build/CMakeFiles/CMakeTmp
...
如您所见,我正在使用GNU 7.2.1
编译器。特别是:
[idf@localhost build]$ sudo dnf install gcc-c++
[sudo] password for idf:
Last metadata expiration check: 0:40:54 ago on Tue 17 Oct 2017 06:52:54 PM EDT.
Package gcc-c++-7.2.1-2.fc26.x86_64 is already installed, skipping.
Dependencies resolved.
Nothing to do.
Complete!
[idf@localhost build]$
我不确定我是否正在运行7.2.x是问题所在。 是否有解决方法允许cmake
了解已安装C编译器?
修改
当我尝试强制编译器设置时,我收到了以下错误:
CMake Deprecation Warning at /usr/share/cmake/Modules/CMakeForceCompiler.cmake:69 (message):
The CMAKE_FORCE_C_COMPILER macro is deprecated. Instead just set
CMAKE_C_COMPILER and allow CMake to identify the compiler.
Call Stack (most recent call first):
CMakeLists.txt:4 (CMAKE_FORCE_C_COMPILER)
CMake Deprecation Warning at /usr/share/cmake/Modules/CMakeForceCompiler.cmake:83 (message):
The CMAKE_FORCE_CXX_COMPILER macro is deprecated. Instead just set
CMAKE_CXX_COMPILER and allow CMake to identify the compiler.
Call Stack (most recent call first):
CMakeLists.txt:5 (CMAKE_FORCE_CXX_COMPILER)
-- Found PythonInterp: /usr/bin/python (found version "2.7.13")
[hunter ** FATAL ERROR **] ABI not detected for C compiler
[hunter ** FATAL ERROR **] [Directory:/home/idf/Documents/opencl/ethminer]
------------------------------ WIKI -------------------------------
https://github.com/ruslo/hunter/wiki/error.abi.detection.failure
-------------------------------------------------------------------
答案 0 :(得分:0)
你可以强迫它,但可能更好地理解它为什么不能编译测试程序。即使强迫编译器,你也可能在同一条船上。如果您执行强制操作,请在CMakeLists.txt中设置:
INCLUDE(CMakeForceCompiler)
CMAKE_FORCE_C_COMPILER(gcc GNU)
CMAKE_FORCE_CXX_COMPILER(g++ GNU)
set(CMAKE_C_COMPILER_WORKS ON)
set(CMAKE_CXX_COMPILER_WORKS ON)