Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top