in the Makefile, do the following changes:
replace -O2(or 3) with -g
CFLAGS = -pipe -g -Wall -W
CXXFLAGS = -g -Wall -W
adding -g means to add debug info in compiling. Your code will be slower. However, you can debug your code with gdb or ddd(graphic gdb). Do not forget to recover your old settings for release version after debugging. -O2 or O3 is for optimization. In debugging, you can not use it.