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
  • 97,681
  • 90
  • 411
  • 885
Alphaneo
  • 12,079
  • 22
  • 71
  • 89

1 Answers1

20

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

Idriss Neumann
  • 3,760
  • 2
  • 23
  • 32
lothar
  • 19,853
  • 5
  • 45
  • 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