Search code examples
clinkerldd

How can I see why libstc++ is needed


I'm writing a C application using openGL. All my code is C99 compliant and I'm not using c++ at all. My program links with openGL libs and SDL2.

Running ldd I get:

linux-vdso.so.1 (0x00007ffd456e0000)
libSDL2-2.0.so.0 => /lib64/libSDL2-2.0.so.0 (0x00007fccdb862000)
libGLEW.so.1.13 => /lib64/libGLEW.so.1.13 (0x00007fccdb5d7000)
libGLU.so.1 => /lib64/libGLU.so.1 (0x00007fccdb368000)
libGL.so.1 => /lib64/libGL.so.1 (0x00007fccdb0d9000)
libm.so.6 => /lib64/libm.so.6 (0x00007fccdadcf000)
libc.so.6 => /lib64/libc.so.6 (0x00007fccdaa0c000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007fccda808000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fccda5ec000)
librt.so.1 => /lib64/librt.so.1 (0x00007fccda3e3000)
libX11.so.6 => /lib64/libX11.so.6 (0x00007fccda0a3000)
libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007fccd9d1c000)
libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007fccd9b04000)
libGLX.so.0 => /lib64/libGLX.so.0 (0x00007fccd98d4000)
libGLdispatch.so.0 => /lib64/libGLdispatch.so.0 (0x00007fccd95eb000)
/lib64/ld-linux-x86-64.so.2 (0x000055a76893d000)
libxcb.so.1 => /lib64/libxcb.so.1 (0x00007fccd93c8000)
libXext.so.6 => /lib64/libXext.so.6 (0x00007fccd91b6000)
libXau.so.6 => /lib64/libXau.so.6 (0x00007fccd8fb1000)

As you can see it links against libstdc++, so I guess another lib need it. How can I check what call is requesting this lib or get more information about the issue? Thanks.


Solution

  • Run your application as LD_DEBUG=all <cmd-line>, e.g.:

    LD_DEBUG=all kwin --version |& grep "needed by"
    

    Outputs:

    ...
    17448:  file=libc.so.6 [0];  needed by kwin [0]
    17448:  file=libxcb-image.so.0 [0];  needed by /lib64/libkwin4_effect_builtins.so.1 [0]
    ...