Thursday, June 27, 2013

Debugging dynamic libraries in NetBeans

When you are trying to debug a dynamic library in C or C++ in Netbeans it is frustrating not to be able to step into the code. Since I continue to forget how to set this up I have made some notes for future reference. Maybe other people will have the same problem.

  1. Build the dynamic library as a project in Netbeans
  2. Add it as a project in the project Properties->Build->Linker->Libraries dialog of the main application
  3. Set the library project to build Debug code
  4. Add the library's source folder in the main application to Project Properties->General->Source folders
  5. Add the library project to Properties->Related Projects of the main application project and check the "build" box. (optional)

Now rebuild the main project or just debug it and you should be able to step in to the library code.

1 comment:

  1. I would just like to point out that, at least for me, you only need to go up to the 3rd step, but the others may be needed on non-linux OS's.

    Anyway thanks a lot for the help, I never actually thought to set the linker to build debug code lol.

    ReplyDelete