问题
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