Enabling debug symbols in shared library using GCC
24,541
You need to use -g
for all the steps (compiling your source files and linking).
Author by
Alphaneo
An electrical engineer, who is a programmer by profession
Updated on March 11, 2020Comments
-
Alphaneo about 4 years
I am creating a shared library using
gcc
and suspect that there may be some memory leaks from the shared library. To debug, I need to enable debug symbols when creating the shared library.To build, I am using
gcc -g ...
(-g
is for enabling debug information)But the library (
*.so
file) size is not changing for both-g
, and without-g
. Besides, I am not getting any useful information from tools likeVALGRIND
.Can anyone point me the mistake?
-
Tim Post almost 15 yearsCan you post the relevant parts of your makefile, or the other CFLAGS being used?
-
Alphaneo almost 15 yearsI added -g to CFLAGS and it worked, thanks !!!
-
-
Manuel over 9 yearsAlso make sure you don't specify -s when linking, because this strips debug info.
-
aleixrocks over 6 yearsThe -g flag is not really needed for the gnu linker as the ld man page says: "-g Ignored. Provided for compatibility with other tools.". It is only required for the compilation stage.