tags:

views:

31

answers:

1

If I run

gcc a.c -L /usr/lib -lexpat 

and both libexpat.a and libexpat.so are in /usr lib which one is used by the linker?

+3  A: 

By default the shared library (.so) will be chosen.

If you want to change this behavior, -static gcc option may be used

-static

On systems that support dynamic linking, this prevents linking with the shared libraries. On other systems, this option has no effect.

Dmitry Yudakov