CMake抱怨“CXX编译器识别未知” [英] CMake complains "The CXX compiler identification is unknown"

查看:1672
本文介绍了CMake抱怨“CXX编译器识别未知”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在关注此主题和此一个来构建我自己的KDE而没有sudo权限。因为在工作站上没有安装Git和CMake。我只是把它们都安装在 / home /< user> 并添加了 / home /< user> / bin / home /< user> / lib 复制到PATH和LD_LIBRARY_PATH。
因为KDE构建只支持CMake,不能配置。所以我必须通过CMake设置前缀,像这样: cmake〜/ kde-devel / src / kdelibs -DCMAKE_INSTALL_PREFIX = / home /< user> 。这时我得到了下面的错误:

I am following this thread and this one to build my own KDE without a sudo permission. Since there was no Git and CMake installed on the workstation. I just had them both installed under /home/< user> and added /home/< user>/bin and /home/< user>/lib to both PATH and LD_LIBRARY_PATH. Since KDE build only supports CMake, not configure. So I have to set the prefix via CMake, like this: cmake ~/kde-devel/src/kdelibs -DCMAKE_INSTALL_PREFIX=/home/<user>. At this point I got below error:

> ~/bin/cmake ~/kde-devel/src/kdelibs -DCMAKE_INSTALL_PREFIX=/home/<user>
-- The CXX compiler identification is unknown
-- Check for working CXX compiler: /home/gnu/bin/c++
-- Check for working CXX compiler: /home/gnu/bin/c++ -- broken
CMake Error at /home/<user>/share/cmake-2.8/Modules/CMakeTestCXXCompiler.cmake:45 (MESSAGE):
  The C++ compiler "/home/gnu/bin/c++" is not able to compile a simple test
  program.

  It fails with the following output:

   Change Dir: /home/<user>/kde-devel/build/kdelibs/CMakeFiles/CMakeTmp



  Run Build Command:/usr/bin/gmake "cmTryCompileExec/fast"
  ...

我检查了有2个C ++编译器:

I checked that there are 2 C++ compilers:

> where c++
/home/gnu/bin/c++
/usr/bin/c++

我应该将CMake默认C ++编译器设置为 / usr / bin / c ++ ?如何?

Should I set CMake default C++ compiler to /usr/bin/c++? and how? Or is there any way to fix this issue?

推荐答案

您的 / home / gnu / bin / c ++

Your /home/gnu/bin/c++ seem to require additional flag to link things properly and CMake doesn't know about that.

要使用 / usr / bin / c ++ 作为编译器运行 cmake -DCMAKE_CXX_COMPILER = / usr / bin / c ++

To use /usr/bin/c++ as your compiler run cmake with -DCMAKE_CXX_COMPILER=/usr/bin/c++.

此外, CMAKE_PREFIX_PATH 变量设置目标文件应安装在哪个目录。它与CMake安装前缀无关,CMake本身已经知道这一点。

Also, CMAKE_PREFIX_PATH variable sets destination dir where your project' files should be installed. It has nothing to do with CMake installation prefix and CMake itself already know this.

这篇关于CMake抱怨“CXX编译器识别未知”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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