TheFuzz
TheFuzz

Reputation: 2623

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

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

Upvotes: 17

Views: 14203

Answers (2)

user502515
user502515

Reputation: 4444

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.

Upvotes: 2

Soo Wei Tan
Soo Wei Tan

Reputation: 3371

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.

Upvotes: 8

Related Questions