在 Eclipse 中使用 C++

安装

  1. 安装Eclipse
    Eclipse下载页
    能够选择Eclipse IDE for C/C++ Developers(内置CDT插件)
    也能够选择安装其它版本号之后再安装CDT插件。
  2. 安装CDT插件
    CDT插件主页
  3. 安装MingGW(32位编译套件)。
    MingGW主页
    下载 mingw-get-setup.exe
    安装完毕后Mingw以及MSYS的bin文件夹应该已经自己主动被加入到了Path环境变量中
  4. 安装Mingw-w64(64位编译套件)
    Mingw-w64主页
    下载 mingw-w64-install.exe (安装时可能须要“以管理员身份执行”)
    安装完毕后将Mingw-w64的bin文件夹加入到Path环境变量中
    Configuring Eclipse for using with MSYS2
 

Eclipse中启动程序时出现“Launch failed. Binary not found.”错误

须要先Build Project,生成Debug目录之后才干执行。
“Launch failed. Binary not found.” error on CDT Kepler Eclipse
 

使用g++编译程序时,出现
“the application has requested the runtime to terminate it in an unusual way”错误以及
“Cannot create temporary file in C:WINDOWS: Permission denied”错误

权限问题。须要暂时“以管理员身份执行”Eclipse
 

程序不能正常启动,命令行下运行出现 (0x0000007b)错误

缺少dll,须要将MinGW的bin文件夹加入到Path环境变量中
 

选择C++编译器版本号(如C++11/14)

Project > Properties > C/C++ Build > Settings > Tool Settings > GCC C++ Compiler > Dialect > Language Standard > ISO C++11(或ISO C++1y)
 

调试程序时显示STL容器的值

首先须要安装Python2.7,然后再配置Eclipse。
Windows > Preferences > C/C++ > Debug > GDB
分别设置GDB debugger 以及 GDB command file的路径。
MingGW的话,应该设置为 MinGW安装文件夹ingdb-python27.exe 和 MinGW安装文件夹in.gdbinit
Mingw-w64的话,应该设置为 Mingw-w64安装文件夹ingdb.exe 和 Mingw-w64安装文件夹etcgdbinit
 

配置Boost库

Project > Properties > C/C++ General > Paths and Symbols > Includes > Gnu C++ > Add > 加入Boost文件夹
 

无法设置断点

Run > Breakpoint Types > C/C++ Breakpoints
How can I enable breakpoints in Eclipse/CDTAsk
 

在Mac上无法调试程序,出现“Error with command: gdb --version”错误

 

编译之前自己主动保存

Windows > Preferences > General > Workspace
勾选 Save Automatically before build
 
原文地址:https://www.cnblogs.com/wzjhoutai/p/6943975.html