I have had terrible problems making an Application Debug using Eclipse C/C++ project with XCode 5.0 and I have finally made it. I have finally been able to successfully debug my application and that's why I decided to make this little tutorial hoping to save time to others.
When trying to debug and application written in C/C++ on Eclipse on Mavericks OS it comes up with "Error gdb -- version".
This is because Eclipse cannot find GDB debug on new Mac OSX because Apple discontinues GDB support in place of LLDB. To check if this is your case simply try to run from Terminal
gdb and it will show up as file not found.
The problem is that LLDB is not configured for Eclipse yet (or the other way around). So how to make your Eclipse debug the application again as in previous 10.8 OS?
First get and compile the GDB. You have two possible options:
- Macports (Unfortunately, the Mavericks release got stuck in Building getext library)
My suggestion is to get it from Homebrew. Check on their web site the download link and install using
ruby -e "$(curl -fsSL https://raw.github.com/mxcl/hebrew/go)"
Let it install. After it successfully installed GDB you need to sign a certificate to make Eclipse able to use GDB otherwise it will show up the error:
Unable to find Mach task port for process-id 28885: (os/kern) failure
(0x5). (please check gdb is codesigned - see taskgated(8))
This means Eclipse can find the GDB now but cannot run it because of the Apple certificates issue.
To sign the GDB application and make it possible that Eclipse runs it follow the guide here:
which can be summarized in:
- Start Keychain Access application (/Applications/Utilities/Keychain Access.app)
Open menu /Keychain Access/Certificate Assistant/Create a Certificate (TOP MENU BAR)
Choose a name (gdb-cert in the example)
3.1 Set "Identity Type" to "Self Signed Root"
3.2 Set "Certificate Type" to "Code Signing"
3.3 Check the flag "Let me override defaults"
3.4 Click several times on "Continue" until you get to the "Specify a Location For The Certificate screen" then set Keychain to "System"
3.5 If you can't store the certificate in the "System" keychain, create it in the "login" keychain, then export it. You can then import it into the "System" keychain.
3.6 Make sure you have the "gdb-cert" in your "System" (left top window)
Select "Get Info" by pressing twice on the fresh made certificate (gdb-cert),
- Open the "Trus"t item, and set "Code Signing to Always Trust"
- Close Keychain Access application
- Restart "taskgated" application from activity monitor
Now you need to sign the Certificated by doing from terminal
$ codesign -s gdb-cert ../path of GDB
$ codesign -s gdb-cert /usr/local/bin/gdb
You are all set now.... ready to debug you C/C++ application on Eclipse on MacOSX Mavericks
Make sure you have all set properly once again double check on Eclipse Menu Run->Debug Configuration->Debugger the line :
GDB Debugger -> /usr/local/bin/gdb (or your local path, check it with "$ which gdb" to get the correct path)
GDB Command file-> .gdbinit
Apple let GDB installed on the Mavericks but they like people squash their heads on the wall before doing a simple Hallo World program. No comment.
Have Fun and I hope to have saved you time!