14

I have a C++ project imported to Eclipse CDT. I can build and run the project using Makefile and argument settings. However, when I tried to add a debug point and run "debug as local c/c++ application", it throws me an error of "Launching projectName" has encountered a problem. Error with command gdb --version By expanding the Details, it gives: Error with command: gdb --version Cannot run program "gdb": Unknown reason

I installed the gdb by Macports before. If I enter command ggdb it returns the version info. If I type which ggdb, it gives /opt/local/bin/ggdb. I tried to add "PATH" to debug configuration -> environment variables and give the path value to it, but it did not work. How should I set the path and link the path please? And what should the variable name be.

The gdb version on my machine is GNU gdb (GDB) 7.7.1

Added: I looked up which ggdb and used the link James provided to change gdb debugger to browse to that path. But it did not work still. enter image description here

enter image description here

enter image description here Thanks.

user2751691
  • 401
  • 2
  • 10
  • 32

1 Answers1

3

It looks like Eclipse is using the default gdb that was on the system before you installed ggdb from macports. This link shows how to change the debugger settings, change it to ggdb which is the name Macport uses.

After installing ggdb from Macports you will have to sign it with a certificate so it will be allowed to control other processes, take a look at "Certifying GDB" here. After creating the certificate, make sure you select the correct name when signing:

$ codesign -s gdb-cert $(which ggdb) /// 'ggdb'
James Moore
  • 447
  • 5
  • 12
  • Did you try the full path `/opt/local/bin/ggdb`? – James Moore Feb 06 '15 at 17:18
  • I did, but the same error still comes. Please see the edited screenshot. Thank you. – user2751691 Feb 06 '15 at 17:23
  • @user2751691 Updated with a link showing how to sign `ggdb` if you haven't done so already. – James Moore Feb 06 '15 at 17:37
  • Thanks a lot. That looks like the trick. But there were commands that require permission so I used `sudo`, now if I debug it, it gives: No symbol table is loaded. Use the "file" command. – user2751691 Feb 06 '15 at 18:14
  • @user2751691 Check that you are running the debug build of your application, not the release through gdb. The debug build should have the option `-g` or `-ggdb` when compiling (eg. `g++ -ggdb projectName.cpp -o prog`). Then run that binary through `gdb`. – James Moore Feb 06 '15 at 18:23
  • I modified my makefile, I made it to `test: $(SIMPLE_CLIENT) g++ -ggdb -I/opt/local/include -L/opt/local/lib $(SIMPLE_CLIENT) -o simple_client -lodbc` Would this be in right format? The -L is with the libraries I need to compile my project. Thank you. – user2751691 Feb 06 '15 at 19:13
  • 4
    Now it does not throw an error, but gives no output, and the progress keeps at 99%... I have to force quit to quit eclipse, lol – user2751691 Feb 06 '15 at 21:06
  • Hi James, just to give u an update. Looks like the problem is from the certificate codesigning. I had the a typo to the name of the certificate, and to make it perfect, I deleted it and added a new one. Somehow the ggdb keeps thinking it has already been code-signed and refuses to accept the new link. Then I reinstalled my machine, did code-signing at one shot, and then it worked... – user2751691 Feb 11 '15 at 19:24