In linux how can I tell if I'm linking to a static or dynamic library?

拜拜、爱过 提交于 2021-02-06 15:15:53

问题


I have a static and a dynamic library with the same name: libclsocket.a and libclsocket.so When I specify what library I want to link to i simply enter -lclsocket as the library. My program complies and runs perfectly fine, but what library am I using? the static library or the dynamic library? I want to give my friend my program, and I'm not sure If i need to include the libraries in the release. C++, codelite, pcLinuxOS 2010


回答1:


You can try running ldd on the executable and seeing if the accompanying .so is being detected as required in the list of dependencies.

ldd man page is here.




回答2:


If you use the -static flag, all components will be made static. And -l may include shared libraries. So specifying the static library filename (e.g. with /usr/lib/libfoo.a for example, no -l prepended), should get you the desired effect.



来源:https://stackoverflow.com/questions/4281360/in-linux-how-can-i-tell-if-im-linking-to-a-static-or-dynamic-library

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