Apologize because for the moment I don't have the environment to experiment and sort out the following questions myself:
1) Let's say I have four library files: libmylib_super.a
and libmylib_super.so
, mylib_dumb.a
and mylib_dumb.so
. While specifying libraries to link to, what are the differences between the following approaches:
A) -l:libmylib_super.a
B) -llibmylib_super
C) -lmylib_super
D) -lmylib_dumb
2) Definition of -static
from man page:
On systems that support dynamic linking, this prevents linking with the shared libraries. On other systems, this option has no effect.
Does this linker option have anything to do with question #1? Or... by any chance will they interfere with each other?
Thanks.
--- edited 2009-12-28 ---
I just got my environment up and experimenting a bit, by linking to Boost date_time library. Say I have three library files: libboost_date_time-mt-d.a
, libboost_date_time-mt-d.so.1.41.0
, libboost_date_time-mt-d.so -> libboost_date_time-mt-d.so.1.41.0
(sym link).
A.1) -l:libboost_date_time-mt-d.a
==> linking OK, binary works even without the library file.
A.2) -l:libboost_date_time-mt-d.a
with -static
==> linking error /usr/bin/ld: cannot find -lm
C.1) -lboost_date_time-mt-d
==> linking OK, binary works but requires the shared library file.
C.2) -lboost_date_time-mt-d
with -static
==> linking error /usr/bin/ld: cannot find -lm
Any idea about the error in A.2 and C.2?
Additionally, while running the program in C.1, it seems searching the shared library file with name libboost_date_time-mt-d.so.1.41.0
but not the libboost_date_time-mt-d.so
. Wouldn't that be inconvenient if the program is running on a system without the exact version of library? What could be the practical way to handle the version while using shared library?