Skip to content

unrecognized command line option “ std=c 11”

cheyiliu edited this page Dec 12, 2014 · 1 revision

原因

  • 出现这个编译错误的原因在g++ gcc 版本不够高。

解决办法

添加源(Ubuntu)

  • sudo add-apt-repository ppa:ubuntu-toolchain-r/test
  • sudo apt-get update

安装4.8版本

  • sudo apt-get install gcc-4.8 g++-4.8

查看本地安装版本

  • ls -lh /usr/bin/g++*

切换版本

  • sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.6 60 --slave /usr/bin/g++ g++ /usr/bin/g++-4.6
  • sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 40 --slave /usr/bin/g++ g++ /usr/bin/g++-4.8
  • sudo update-alternatives --config gcc 选择4.8的序号

再次查看g++版本

  • g++ --version

ref

Clone this wiki locally