I have recently started using Linux as a tool for programing. In my book, I have seen that the GCC is used with 2 options: -g
and -o
. Now, I know that -o
is to set a filename, but what is the purpose of -g
? I thought it might relate to debugging, but also programs compiled without the -g
argument are debuggable. So what is it?
|
||||
|
To quote from the manual: |
|||
|
-g option enables use of extra debugging information that GDB can use. Here's example of C code:
let's compile it without -g option and see gdb output:
And now with -g option:
As you can see, now there is information about line with error. |
|||
|
It is related to debugging: (from
You can run a debugger on a program without debugging symbols in it, but it is like trying to find your keys in the dark. Eg, you cannot set breakpoints:
That's a big hassle. |
|||
|