Qt Creator无法在linux中找到CMAKE_CXX_COMPILER编译器64位

时间:2018-06-08 06:02:50

标签: c++ linux qt cmake mint

我尝试使用cmake在Qt Creator 4.7.0-beta1中构建一个简单的hello world c ++应用程序,我收到以下错误:

Running "/usr/bin/cmake /home/cpnblank/Documents/vulkandev/cmaketest '-GCodeBlocks - Unix Makefiles' -DCMAKE_CXX_COMPILER:STRING= -DCMAKE_C_COMPILER:STRING=/usr/bin/gcc -DCMAKE_PREFIX_PATH:STRING=/home/cpnblank/Qt/5.11.0/gcc_64 -DQT_QMAKE_EXECUTABLE:STRING=/home/cpnblank/Qt/5.11.0/gcc_64/bin/qmake" in /tmp/QtCreator-CRirhE/qtc-cmake-DuSxtHku.
-- The C compiler identification is GNU 5.4.0
-- The CXX compiler identification is unknown
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
CMake Error at CMakeLists.txt:3 (project):
  No CMAKE_CXX_COMPILER could be found.

通过设置环境告诉CMake在哪里找到编译器   变量" CXX"或CMake缓存条目CMAKE_CXX_COMPILER到完整路径   编译器,或编译器名称,如果它在PATH中。

- 配置不完整,发生错误! 另见" /tmp/QtCreator-CRirhE/qtc-cmake-DuSxtHku/CMakeFiles/CMakeOutput.log"。 另见" /tmp/QtCreator-CRirhE/qtc-cmake-DuSxtHku/CMakeFiles/CMakeError.log"。 *** cmake进程退出,退出代码为1。

我安装了build-essentials,并且还将cxx路径设置为g ++。我还卸载并重新安装了g ++和gcc。

有什么想法吗?

2 个答案:

答案 0 :(得分:1)

发生这种情况是因为您的qtproject套件找不到适合cmake的编译器。

为方便CMAKE,请先安装Ninja-Build。另外,您将需要GCC或Clang和GDB。

apt install ninja-build gcc gdb clang

为方便qt环境设置,您可以使用:

apt install qt5-defaultapt install qt4-default

现在忍者将尝试正确配置您的cmake
您可能还需要转到:

  

工具->选项->套件-> ...

...然后选择您需要使用的工具包,然后在“编译器”部分中为g ++编译器选择gcc或clang c ++,为c编译器选择gcc或clang c。

答案 1 :(得分:0)

This error appears when the compiler is not correctly set, and thus, cmake is not able to find it.

This is obvious, but when you are using QtCreator, you have to take into account where this information is defined. It is defined in the "kit" specification.

First of all, check if your "Kit" is properly configured. Go to the menus and select:

Tools->Options.

Then, in the Options window, select "Build & Run" in the left column. Then, select the "Kits" tab in the right panel. There you can see a list of the available Kits.

Select the kit you want to use. If you have more than one option and you don't know which one choose to use the default option (i.e. "Desktop Qt 5.2.1 GCC 64bit (default)").

In the kit configuration list, check the row named "Compiler". If the C++ compiler is configured as "No compiler, there is the problem. Select one of the compilers in the list (you can select the base GCC (C++) for example). Then press the "OK" button, and try to generate the project from scratch (remove the generated files and open it again).

If the compiler is configured, make sure that is the correct one, and check if the path to the binary is correct.

NOTE: If the list has not the desired compiler, you can add it in the "Compilers" tab. There, press "Add" button and select the desired options.

NOTE2: If the compiler list is empty...maybe you need to install QtCreator again.