Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mac C++/eclipse cannot debug: Error while launching command: gdb --version

I am using c++/eclipse kepler on mac, and I cannot debug any project. The error is "Error while launching command: gdb --version" Besides that, I can build and run my code using other libraries.

I searched a site that is similar to my problem: Debugger for C++ eclipse gives the following error. 'Launching program name' has encountered a ... Error while launching command: gdb --version

But what should I change if I am using a mac?

like image 859
user3000888 Avatar asked Jan 13 '14 00:01

user3000888


People also ask

How do I get GDB on my Mac?

As with GCC, the easiest way to install GDB is through Homebrew. In a Terminal window, run the command brew install gdb , and wait for it to complete. (As usual, it may ask for your password.) Now, we need to code-sign the GDB executable, so it will be allowed to control other processes, as necessary for a debugger.

Does Eclipse use GDB?

The default debugger used by Eclipse is GDB, but this can be replaced with UDB to allow time travel debugging. This section of the user guide describes the steps that are required in order to use UDB in Eclipse in the following contexts: Debugging a local target.


2 Answers

You can fix this by specifying the full path to gdb. You can do this separately for each debug configuration, and you can also set the default gdb location in the preferences under C/C++ > GDB. For example, if you installed gdb via Homebrew, then it's probably located under /usr/local/bin:

GDB Debug Configuration

And here's a screenshot of the Preferences:

GDB Preference

I still don't know why Eclipse can't find GDB even though it is on my path. I guess it doesn't use my .bash_profile or my .bashrc? You could try symlinking gdb into /usr/bin. Maybe Eclipse will look there.

Edit: I tried the symbolic link idea and now Eclipse can debug, but it crashes inexplicably while doing so! So, I guess... don't do that?

like image 52
Neil Traft Avatar answered Oct 12 '22 16:10

Neil Traft


This guide from a UC Irvine Computer Science professor's page is a very well-written, detailed, and Mac-specfic description of all the steps involved in installing GDB, creating a certificate, signing GDB using that certificate, and finally configuring Eclipse. I was found this very helpful as someone unfamiliar with each of these steps.

GDB Installation on Mac OS X

like image 12
Chris Hawk Avatar answered Oct 12 '22 17:10

Chris Hawk