【发布时间】:2021-10-17 09:42:11
【问题描述】:
我正在尝试编译一个库。我使用了 Cmake,它的工作原理是:
“LibraryName 需要语言方言“CXX17”,但 CMake 不知道用于启用它的编译标志。
之后我使用make进行编译:但它在输出中给出了以下错误(编译一些cpp文件时):
cc1: warning: command line option ‘-fpermissive’ is valid for C++/ObjC++ but not for C [enabled by default]
env.hpp:10:1: warning: scoped enums only available with -std=c++11 or -std=gnu++11 [enabled by default]
enum class PlacementMethod {
alltoallv.cpp:19:7: error: ‘AlltoallvMethod’ is not a class or namespace
if (AlltoallvMethod::NONE == environment::alltoallv) {
alltoallv.cpp:44:8: error: ‘AlltoallvMethod’ is not a class or namespace
case AlltoallvMethod::AUTO: {
alltoallv.cpp:43:10: warning: enumeration value ‘AUTO’ not handled in switch [-Wswitch-enum]
make[2]: *** [CMakeFiles/tempi.dir/src/alltoallv.cpp.o] Error 1
make[1]: *** [CMakeFiles/tempi.dir/all] Error 2
make: *** [all] Error 2
我该如何解决这个问题?
我无法修改我的环境或使用“sudo”命令,因为我在公共集群上工作并且我不拥有这些权限。
CMake 输出:
../../cmake-3.21.1-linux-x86_64/bin/cmake ..
-- Build type: Release
-- GIT_REFSPEC=refs/heads/master
-- GIT_HASH=fe16ae7692da83e9cd247782f596a46a1d010699
-- GIT_LOCAL_CHANGES=DIRTY
-- MPI include dir: /opt/ohpc/pub/mpi/openmpi-gnu/1.10.7/include
-- -march=native detected
-- -march=native detected
-- -march=native detected
-- -march=native detected
-- -march=native detected
-- -march=native detected
-- -march=native detected
-- -march=native detected
-- -march=native detected
-- -march=native detected
-- -march=native detected
-- -march=native detected
-- -march=native detected
-- define TEMPI_ENABLE_KAHIP
-- OpenMP support detected
-- -march=native detected
-- nvToolsExt found: /hpc/share/tools/cuda/10.2.89/lib64/libnvToolsExt.so
-- nvidia-ml found: /hpc/share/tools/cuda/10.2.89/lib64/stubs/libnvidia-ml.so
-- Configuring done
CMake Error in CMakeLists.txt:
Target "tempi" requires the language dialect "CXX17" , but CMake does not
know the compile flags to use to enable it.
-- Generating done
CMake Generate step failed. Build files cannot be regenerated correctly.
【问题讨论】:
-
您使用的是什么版本的 GCC 和 CMake?
-
您的构建系统可能很古老,因为 gcc 告诉您启用 C++11。
-
gcc --version 输出:gcc (GCC) 8.3.0,我使用了他们网站上可用的最后一个 CMake 版本:3.21
-
更新问题。
-
奇怪的是CMake应该知道如何设置
-std=c++17,也许在构建之前尝试手动设置CXXFLAGS=-std=c++17