展会信息港展会大全

eclipse 配置 C++ 11 -- ubuntu 12.04
来源:互联网   发布日期:2016-01-14 14:39:12   浏览:2621次  

导读:安装g++ 4.8 sudo apt-get install python-software-properties sudo add-apt-repository ppa:ubuntu-toolchain-r/test sudo apt-get update sudo apt-get install g++-4.8 sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 50 最后看...

安装g++ 4.8

sudo apt-get install python-software-properties

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

sudo apt-get update

sudo apt-get install g++-4.8

sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 50

最后看看 g++ 的版本号,看是否安装成功

g++ --version

配置全局的编译参数:

选中eclipse工具栏 Project -> Properties -> C/C++ Build -> Settings -> Miscellaneous. 在右边的 Other flags 添加 -std=c++11

如果只是针对某个工程,则右键选中 目标工程-> Properties -> C/C++ Build -> Settings -> Miscellaneous. 在右边的 Other flags 添加 -std=c++11

配置eclipse CDT 的 indexer。方便编辑器正确的解析C++11的关键字、符号等。

选中eclipse工具栏 Project -> Properties->C/C++ General -> Preprocessor Include Paths, Macros etc.:

选择标签页“Providers”

Configuration栏选择Debug(之后还可配置“Release”)

在标签页“Providers”下选中"CDT GCC Built-in Compiler Settings"。

反勾选 Use global provider shared between projects.

在Command to get compiler specs栏后面添加 "-std=c++11" (不带引号);

最后选则apply 和 OK。

最后重新build C/C++ 的 indexer. Project -> C/C++ Index -> Rebuild.

参考文章

http://askubuntu.com/questions/271388/how-to-install-gcc-4-8-in-ubuntu-12-04-from-the-terminal

https://gist.github.com/omnus/6404505

http://stackoverflow.com/a/17499266

http://stackoverflow.com/a/15321753

赞助本站

人工智能实验室
AiLab云推荐
展开

热门栏目HotCates

Copyright © 2010-2024 AiLab Team. 人工智能实验室 版权所有    关于我们 | 联系我们 | 广告服务 | 公司动态 | 免责声明 | 隐私条款 | 工作机会 | 展会港