1

Eclipse 4.6 support c++11

 2 years ago
source link: https://forrestsu.github.io/posts/tools/eclipse-4-6-support-c++11/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

1 配置MinGW-w64环境

  使用MinGW时(其中g++ version 4.9.2 ),发现std::to_string()函数无法使用,还是推荐使用snprintf()。   如果在Windows下搭建MinGW环境,推荐使用MinGw-w64,std::to_string()等函数都能正常使用(其中g++ version 6.3.0),所以后续推荐使用64位版本的MingW,可在nuwen下载MinGW-w64,即mingw-14.1-without-git.exe。

然后双击exe,即可解压到D:\Portable\,配置系统环境变量MINGW_HOME。

最后在Path后追加 ;%MINGW_HOME%\bin,完成配置。

2 支持C++ 11

There’s two things you have to do, first you need to setup your compiler, then you need to setup CDT’s language processor. Since you didn’t mention which compiler you’re using, I’ll assume it’s GCC but the steps will be similar for other compilers. (Note that you need a compiler that supports C++11, of course.)

Setting up the compiler is fairly straightforward:

  1. Right click your project and click Properties
  2. Under C/C++ Build click Settings
  3. Under GCC C++ Compiler, click Miscellaneous
  4. In the Other Flags box, append “-std=c++11” to the list of tokens.
  5. Click Apply and OK

At this point you should be able to rebuild your project and get it to run. But CDT still may show errors for C++11 includes. Here’s how you can resolve that:

  1. Right click your project and click Properties
  2. Under C/C++ General click “Preprocessor Include Paths, Macros”
  3. Select the Providers tab
  4. There should be an item in the list that says something like “GCC Built in Compiler Settings”. Select this entry.
  5. Uncheck the “Use global provider…” option
  6. Under the list there’s an box that says “Command to get compiler specs.” Append “-std=c++11” to this.
  7. Move the “GCC Built in Compiler Settings” provider at the top of the list using the ‘Move Up’ button on the right.
  8. Click Apply and then OK.
  9. Back in your Eclipse workspace, select the Project Menu, C/C++ Index, and click “Re-resolve unresolved includes.”

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK