开发者

What's the difference between "gcc -lname" and "gcc libname.so ..."

开发者 https://www.devze.com 2023-03-21 19:12 出处:网络
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) i

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.)

0

精彩评论

暂无评论...
验证码 换一张
取 消