qtcreator中NO CMAKE_CXX_COMPILER could be found

描述

linux下用qtcreator打开cmake项目,发现cmake提示找不到c++编译器

CMAKE: “No CMAKE_CXX_COMPILER could be found.”

但是我明明装了g++和clang
报错提示我们可以设置环境变量或者cmake entry

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

试了都没有用,因为我们没有用cmake环境或者shell环境,而是在qtcreator环境下
所以需要修改qtcreator的kit,so上是这样说的,在

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.

在qtcreator选项->build&run->kit中设置c++编译器就可以

原帖:
https://stackoverflow.com/questions/50754287/qt-creator-cant-find-cmake-cxx-compiler-compiler-in-linux-mint-64-bit

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
"No CMAKE_CXX_COMPILER could be found"是一个编译器到的错误提示。这可能是由于没有正确设置编译器的路径或没有安装编译器导致的。引用提到了两种解决方法,一种是通过设置环境变量"CXX"来告诉CMake编译器的路径,另一种是通过设置CMake缓存条目CMAKE_CXX_COMPILER来告诉CMake编译器的完整路径或路径名。 在引用提到了一个具体的例子,该用户在全新安装的Ubuntu22.04版本上安装了Qt,并运行Qt Creator自带的示例时遇到了这个问题。根据引用内容的提示,用户检查了构建和运行设置,并发现GCC和G栏是空的。然后用户在终端运行了"gcc --version"和"g++ --version"命令,发现有相关的版本信息。接着用户在Qt的构建和运行设置到了gcc和g++,并确认它们的默认路径为"/usr/bin/gcc"和"/usr/bin/g++"。 因此,问题的答案是"no cmake _cxx"是一个编译器到的错误提示,可能是由于没有正确设置编译器的路径或没有安装编译器导致的。你可以通过设置环境变量"CXX"或设置CMake缓存条目CMAKE_CXX_COMPILER来解决这个问题。另外,你可以检查一下你的系统是否安装了正确的编译器,并确保在Qt的构建和运行设置正确设置了编译器的路径。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* *3* [No CMAKE_CXX_COMPILER could be found](https://blog.csdn.net/weixin_49369227/article/details/129913371)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 100%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值