0

我经常遇到这个问题:

[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
-------------------------------------------------------------------
4

1 回答 1

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)
于 2017-10-18T00:05:10.670 回答