24 August 2008

MinGW and Gdb in NetBeans

I configured NetBeans to use MinGW (Minimalist GNU for Windows), but when trying to debug an old C++ program, NetBeans kept displaying this error message: Gdb could not load your program. Terminating debug session. The version of gdb matched the MinGW distribution, so that wasn't the problem. After the usual bit of head-scratching, I ran gdb in a console and got this message: Reading symbols from <file>...(no debugging symbols found)...done. I manually compiled the source using g++ and found that my program was 3 times bigger than the NetBeans compiled version. So, the source of the problem is in the Makefile.

It turned out that when I imported my project into NetBeans, I forgot that my Makefile had this rule: $(CXX) -Wall -ggdb -s. The command-line option -s told the linker to strip all symbols, so gdb couldn't debug my program. Duh.