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

43,019

Solution 1

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?

Solution 2

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

Solution 3

I had the same problem. I solved it by:

  1. Install a gdb - ( I used 7.8.1) - compile and install it. It got installed in usr/local/bin
  2. Codesigning certificate
  3. Open eclipse executable using sudo. Otherwise I still get the error.

I am on OS X. Hope this helps.

Solution 4

I had this error too now, and spent more than an hour looking for it. In my case, the path was correct, and eclipse seemed to fail to start "any" executable as debugger. (I tested with gksudo cat, but it clearly never got to effectively running it).

The final reason was that I had put in my eclipse.ini -Xms1G and -Xmx1G. It seemed to already use the full memory for the indexer, and trying to allocate some more memory to start the debugger failed with an "unkown" error. Removing the memory limitations fixed the issue.

Hope this helps someone

Share:
43,019

Related videos on Youtube

user3000888
Author by

user3000888

Updated on May 31, 2020

Comments

  • user3000888
    user3000888 almost 4 years

    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?

    • mostafa tourad
      mostafa tourad over 10 years
      Do you actually have gdb installed? Run gdb --version within your terminal.
    • dbrank0
      dbrank0 over 10 years
      In my experience this is eclipse bug related to system PATH. Check if it's valid or if you can simplify it.
    • user3000888
      user3000888 over 10 years
      Yes, I have gdb, instead it changes its name to ggdb, but I still cannot debug
    • Neil Traft
      Neil Traft over 10 years
      Are you on OS X Mavericks? Also, how do you know it's changing the name? What do you mean by that?
  • MGR
    MGR almost 7 years
    I found it working when the environment variable settings in eclipse was updated with proper path to gdb.exe.
  • nyg
    nyg over 5 years
    I can't believe this error can comme from a performance issue... I'm running Eclipse inside a VM, and after reducing the number of CPUs the VM can use, Eclipse could not start any debugger... I've reverted the change and the debugger starts fine now... thanks a lot!