0

我正在尝试使用 cmake 构建pdf2htmlEX

这是错误消息:

CMake Error at CMakeLists.txt:108 (message):
  Error: your compiler does not support C++0x, please update it

这是clang编译器的版本号

$ which clang
/usr/bin/clang
$ which c++
/usr/bin/c++
$ clang --version
Ubuntu clang version 3.5-1ubuntu1 (trunk) (based on LLVM 3.5)
Target: x86_64-pc-linux-gnu
Thread model: posix
$ c++ --version
Ubuntu clang version 3.5-1ubuntu1 (trunk) (based on LLVM 3.5)
Target: x86_64-pc-linux-gnu
Thread model: posix

经过快速测试,我意识到clang不支持-std=c++0x. 我删除了clang并安装了g++。以下是相关版本信息:

$ which g++
/usr/bin/g++
$ which c++
/usr/bin/c++
$ g++ --version
g++ (Ubuntu 4.8.2-19ubuntu1) 4.8.2
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ $ c++ --version
c++ (Ubuntu 4.8.2-19ubuntu1) 4.8.2
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

我运行了一个非常简单的测试,似乎 g++ 可以接受c++0x参数

g++ -std=c++0x /tmp/c/t.cpp

我在 Ubuntu 14.04.1 LTS 上运行 cmake

制作

它的版本是cmake version 2.8.12.2

以下是相关代码 CMakeLists.txt

include(CheckCXXCompilerFlag)
check_cxx_compiler_flag("${CMAKE_CXX_FLAGS}" CXX0X_SUPPORT)
if(NOT CXX0X_SUPPORT)
    message(FATAL_ERROR "Error: your compiler does not support C++0x, please update it.")
endif()

我是 cmake 的新手,所以不知道如何确定check_cxx_compiler_flagcmake

4

1 回答 1

1

原来是“cmake”缓存问题

当我第一次运行 cmake 时,它​​选择了clang++不支持该选项的-std=c++0x选项。即使clang已被删除并正确g++安装,cmake的后续运行仍会报告相同的缓存结果。

这是解决方案:

在再次运行 cmake 之前,删除文件夹CMakeFiles和文件CMakeCache.txt

于 2014-09-29T10:46:14.977 回答