我尝试使用 cmake 更改编译器:
SET(CMAKE_C_COMPILER "/opt/rh/devtoolset-2/root/usr/bin/gcc")
SET(CMAKE_CXX_COMPILER "/opt/rh/devtoolset-2/root/usr/bin/g++")
Run Code Online (Sandbox Code Playgroud)
我在项目开始时调用“PROJECT”命令之前执行此操作。但是当我调用 cmake 时出现无限循环,我有以下输出:
-- The C compiler identification is GNU 4.8.2
-- The CXX compiler identification is GNU 4.8.2
-- Check for working C compiler: /opt/rh/devtoolset-2/root/usr/bin/gcc
-- Check for working C compiler: /opt/rh/devtoolset-2/root/usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /opt/rh/devtoolset-2/root/usr/bin/g++
-- Check for working CXX …Run Code Online (Sandbox Code Playgroud) 在 Red Hat Linux 工作站上,我使用 devtoolset2 给出以下命令:
scl enable devtoolset-2 bash
Run Code Online (Sandbox Code Playgroud)
然后,当我调用 gcc --version 时,我得到:
gcc (GCC) 4.8.2 20140120 (Red Hat 4.8.2-15)
Copyright (C) 2013 Free Software Foundation, Inc.
但是如果我编译我的程序(用cmake生成的malkefile,添加以下行:
if(UNIX)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=c++11")
endif()
Run Code Online (Sandbox Code Playgroud)
我有以下错误消息:
cc1plus: error: unrecognized command line option "-std=c++11"
Run Code Online (Sandbox Code Playgroud)
如果我编译将 -std=c++11 替换为 -std=c++0x ,我会得到这些消息:
nullptr wasnt declared in this scope.
Run Code Online (Sandbox Code Playgroud)
考虑到 nullptr 是关键字,如何无法识别它?
我不明白,如果你有任何想法......