gcc linker finding both .so and .a in the library path which is chosen?

眉间皱痕 提交于 2019-12-23 16:27:33

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/2545907/gcc-linker-finding-both-so-and-a-in-the-library-path-which-is-chosen

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!