2

I encounter the problem that even though after installing gdb Eclipse still gives out the error message 'Error with command --gdb version' whenever I try to compile my code. I exactly followed this guide: Eclipse GDB MacOSX Mavericks, but it didn't fix it. Any ideas what else could be wrong?

Community
  • 1
  • 1
azureai
  • 181
  • 1
  • 13

2 Answers2

0

You have to change the path of GDB in Eclipse from gdb to /usr/local/bin/gdb or similar. In other words, specify the full path.

Running which gdb in terminal should tell you what is the right path.

You can set this property in Eclipse globally (Preferences -> C/C++ -> Debug -> GDB) or per project. I suggest changing it globally but be aware that run configurations created before you changed the value will still have the old value and will need to be updated manually. Open the run (debug) configuration and check the "Debugging" tab.

Marco83
  • 1,181
  • 1
  • 10
  • 28
0

While Marco83's answer certainly worked, I wanted something that would work out-of-the-box for my students, only some of whom are using Mac OS X (the others have Windows computers using MinGW and Linux Computers).

I figured that Eclipse might be looking for gdb in the same directory that it found gcc and g++, and so I went to /opt/local/bin where 'port' put ggdb and added soft links there to /usr/bin/gcc and /usr/bin/g++
At the same time, I added a soft link from gdb to ggdb

So far so good, but the default PATH environment variable on my El Capitan has /usr/bin coming before /opt/local/bin

I changed the order in PATH in a terminal window and launched eclipse from the terminal window with something like ...

.../Applications/Eclipse.app/Contents/MacOS/eclipse

and it seems to prove my figuring to be correct. Eclipse now found gdb without any modifications inside the program. That leaves for me easily launching eclipse with the desired PATH order.

I edited .../Applications/Eclipse.app/Contents/Info.plist and added the "Environment variables" property list child and to that a "PATH" property with the full path exactly as I wanted.

Then I used the /System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister program in Terminal to force update the LaunchService database (as I learned on StackExchange) or you could reboot or something like that.

This seems to work on El Capitan. Any improvements on this would be welcomed.