St.Antario
St.Antario

Reputation: 27435

How to link a binary with the library with the version name

Let I've compiler a so shared library with g++ as the following

g++ -shared -Wl,-soname,libtest.1.0 -o libtest.1.0.1 test.o

But when I'm trying to link a binary with this lib a write the following:

g++ -o bin -L. -ltest -Wl,-rpath.

linker trying to search libtest.so without any version number.

How can I pass to the -l linker option the lib name with the version number?

Upvotes: 2

Views: 1243

Answers (1)

Lee Duhem
Lee Duhem

Reputation: 15121

Try this:

g++ -o bin -L. -Wl,-rpath=. -l:libtest.1.0.1

Normally, on Linux at least, with -lnamespace, ld will try to find a file named libnamespace.so or libnamespace.a to link in its library search path list, but with -l:namespace, ld will search for a file named namespace in its library search path list.

Upvotes: 5

Related Questions