I am using scientific linux. I am dealing with a huge amount of code in C++ with tons of cpp files. Right now, it compiles successfully, but the values/data I'm getting are definitely wrong. Also, for some small changes I make to the code causes seg faults.
In the directory user/project/Build
, I enter make
to compile and link all the cpp files. I then have to go to user/project/Build/bin/project
to run the project binary by typing user/run/run.sh
When I go to directory /user/project/Build/bin
and then type gdb project
and then run
, I see
Program exited with code 01. Missing separate debuginfos, use: debuginfo-install glibc..
If I try to set a breakpoint, such as by break test.cpp:19
, I get the message No source file named test.cpp.
Make breakpoint pending on future shared library load?
But I clearly have a source file named test.cpp
How can I set breakpoints? Considering that I'm a beginner with Unix, should I use another IDE such as emacs or Qt creator?
Did you read the documentation of GDB? It is definitely worthwhile to read it. Read also some tutorial on
gdb
If your
Makefile
-s are generated by cmake, you should also study the documentation ofcmake
and the documentation ofmake
. See also this answer to a related question.Did you compile all your software with
g++ -Wall -g
(and without any optimization flags like-O1
or-O2
) - or perhaps even-g3
instead of-g
?You might even install debugging variants of the major libraries you are using (e.g. packages like
glibc-debuginfo
etc...)You probably want to specify (for
gdb
) the source directories to search with thedir
command ofgdb
...And yes, I recommend using
emacs
. But above all, I strongly recommend spending hours (and perhaps days or even weeks) to learn more about Linux and software development on it (there are lots of books, websites, tutorials and other training, ... about that). Maybe start with a small, hello-world like, program (learning how to compile it withg++
and to debug it withgdb
). Then try to compile and debug a small (e.g. of a hundred thousand lines of source code) free software that you like (e.g. fishshell or anything you've got from sourceforge or github), just to get a feeling of how such software is built.If you are using (or improving) a big scientific software, it probably has some community website, mailing list, or forum for help (see geant or kiva or aster as examples, which I only know by name!). Please also use them.
PS. It is not mostly a matter of choosing tools: you are using the good ones (GCC i.e.
g++
,emacs
,gdb
,make
,grep
or ack, etags, git,awk
, ....). It is a matter to get the knowledge -spending weeks or months of your time- about how to use them wisely and combine their use. See also this & that.