How to find library type (.so or .a) in C ++ / UNIX
2 answers
Try file -L <library name> | grep shared
if this produces any output, the file is dynamically linked. Alternatively, you can do ldd <library name> | grep 'not a dynamic executable'
that which produces the output if it is static. Hopefully this answers your question, I would add a comment to Aviator, but I cannot comment (yet).
Option -L
to force file downloads to unbind symbolic links, which is not the default behavior if POSIXLY_CORRECT is not defined (as is the case on my system).
Script example:
if [-z "$ (file -L | grep shared)"]; then echo "not a dynamic lib"; else echo "dynamic lib";
+1
source to share