It 开发者_JAVA技巧seems to me that both work, any difference?
Does gcc libname.so ...
statically links libname.so
or not?
gcc -l
looks for both static and dynamic libraries (unless -static
is given) in its library search path. gcc ... libname.so
links dynamically with libname.so
in the current directory.
gcc ... libname.so
is the same as gcc -shared -L. -lname
You can't statically link a dynamic library. You're just playing with two different ways to give the name of the library to the compiler driver program (gcc). larsmans is right that the -l option will look for both shared and then static libraries (unless you specify -static on the gcc call.)
精彩评论