16

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 like VALGRIND.

Can anyone point me the mistake?

jww
  • 90,984
  • 81
  • 374
  • 818
Alphaneo
  • 11,431
  • 20
  • 68
  • 88

1 Answers1

19

You need to use -g for all the steps (compiling your source files and linking).

Idriss Neumann
  • 3,656
  • 1
  • 22
  • 31
lothar
  • 19,177
  • 5
  • 44
  • 59
  • 4
    Also make sure you don't specify -s when linking, because this strips debug info. – Manuel Sep 10 '14 at 09:06
  • 2
    The -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. – aleixrocks Nov 16 '17 at 16:59