Mister Yes
Mister Yes

Reputation: 23

Why libc dependency despite of -nostdlib

I would like to control dependency to libc during my shared library building.

So, I've introduced -nostdlib in command line (with clang 8 or gcc 9; it's the same).

This works if I do not link my lib against some other shared library (libossp-uuid, to name it).

But not with -lossp-uuid.

cc -fPIC -shared -nostdlib -olibmain.so   main.c -L/usr/local/lib -lossp-uuid -I/usr/local/include

ldd shows a dependency to libc.so.7.

ldd ./libmain.so
./libmain.so:
        libossp-uuid.so.16 => /usr/local/lib/libossp-uuid.so.16 (0x80066f000)
        libc.so.7 => /lib/libc.so.7 (0x80024a000)

The question is why I can't. Is there a workaround.

Thank you very much for any smart suggestion. This is a great mystery for me.

Upvotes: 1

Views: 350

Answers (1)

Florian Weimer
Florian Weimer

Reputation: 33717

The dependency appears to stem from libossp-uuid.so.16. You will have to build that library with -nostdlib as well.

Upvotes: 1

Related Questions