可以先安裝個CDT插件:
eclipse菜單 -> Help -> Install New Software... -> Work with (Add..)
Name:CDT
Location:http://download.eclipse.org/tools/cdt/releases/galileo
finish
build錯誤:
launch failed, binary not found
解決方法:
debug錯誤:
"Launching projectName" has encountered a problem. Error with command gdb --version
Error with command: gdb --versionCannot run program "gdb": Unknown reason
解決方法:
1.安裝brew
詳見:http://www.cnblogs.com/SZxiaochun/p/7674316.html
2.使用brew安裝GDB
brew install gdb
3.配置eclipse,進行debug。
偏好設置->Preferences > C/C++ > Debug > GDB
如果你已經創建了一些工程,比如上面的測試程序,可以在 Run -> Debug Configurations進行修改。
4.創建證書 (前3步走完之后,調試不報錯的話,就不需要這一步)
詳見:http://www.cnblogs.com/SZxiaochun/p/7747989.html
如果這一步走完,調試還報gdb認證錯誤的話。就刪除 gdb ,再重新裝一下,重新 codesign -s gdb-cert /usr/local/bin/gdb 一下就好了。(親測)
如果gdb報錯:gdb terminated with signal ?, unknown signal
解決方法:
Create a .gdbinit file in your home-direcetory and write "set startup-with-shell off" in it.
File can be created using vi ~/.gdbinit
.
然后修改下eclipse中 Debug Configuartions 的配置:
重啟eclipse就可以debug了。
效果: