R__
R__

Reputation: 1531

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

It seems to me that both work, any difference?

Does gcc libname.so ... statically links libname.so or not?

Upvotes: 0

Views: 498

Answers (3)

Wexxor
Wexxor

Reputation: 1909

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

Upvotes: 0

Je Rog
Je Rog

Reputation: 6011

gcc ... libname.so is the same as gcc -shared -L. -lname

Upvotes: 0

Fred Foo
Fred Foo

Reputation: 363797

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.

Upvotes: 2

Related Questions