Does gcc linker find both .so and .a in the selected library path?

If I run

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

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

+3
source share
1 answer

By default, a shared library (.so) will be selected.

If you want to change this behavior, you can use the -staticgcc option

-static

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

+2
source

Source: https://habr.com/ru/post/1739153/


All Articles