Cmake错误设置编译器 [英] Cmake error setting compiler

查看:667
本文介绍了Cmake错误设置编译器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于某些原因,CMake的C和C ++编译器默认设置为 / usr / bin / qcc 。我已遵循此帖,尝试了命令 p>

For some reason, CMake's C and C++ compilers are set by default to /usr/bin/qcc. I've followed this post and tried the command


cmake -D CMAKE_C_COMPILER = / usr / bin / gcc -D CMAKE_CXX_COMPILER = / usr / bin / g ++

cmake -D CMAKE_C_COMPILER=/usr/bin/gcc -D CMAKE_CXX_COMPILER=/usr/bin/g++

但我得到错误


CMake错误:源目录[current directory ] / CMAKE_CXX_COMPILER = / usr / bin / g ++不存在。

CMake Error: The source directory [current directory]/CMAKE_CXX_COMPILER=/usr/bin/g++" does not exist.

为什么CMake将我的命令解释为目录,是设置CMake编译器的正确方法?

Why is CMake interpreting my commands as a directory, and what is the correct way to set CMake's compilers?

推荐答案

你有正确的想法,但是你想要的命令行是:

You've got the right idea, however the command line you want is:

cmake -DCMAKE_C_COMPILER=/usr/bin/gcc -DCMAKE_CXX_COMPILER=/usr/bin/g++ <path_to_source>

区别是微妙的。 -D 和变量被设置,这就是为什么CMake解释你的变量赋值为一个目录。另外,CMake对C ++特定的变量使用 CXX ,这使它与Make保持一致。

The differences are subtle. There should be no space between the -D and the variable being set, which is why CMake is interpreting your variable assignment as a directory. Also CMake uses CXX for C++ specific variables, which keeps it consistent with Make.

这篇关于Cmake错误设置编译器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆