Results 1 to 4 of 4
Hi
I have a c++ project in which I compile a shared library and then link an executable against it. This used to work fine for me
so, i have ...
- 11-12-2009 #1Just Joined!
- Join Date
- Nov 2009
- Posts
- 2
gnu linker: executable cannot find a versioned shared library
Hi
I have a c++ project in which I compile a shared library and then link an executable against it. This used to work fine for me
so, i have a shared library, let's say "libmylib.so",, created with
and it is located in /home/user/project/lib/c++Code:g++ -shared -Wl,-soname,libmylib.so -o libmylib.so [other otpions]
then i have an executable in [project-path]/cmd/c++ (let's call it "test"), which is linked against this library as
and this all works fine, ldd shows that the executable is able to locate all libraries and it runs as it is supposed to.Code:g++ -Wl,-rpath=/home/user/project/lib/c++ -o test -lmylib -L /home/user/project/lib/c++ [other options]
Recently, I decided to introduce version numbering to my project. So if the version number is 1.2.3 the library linking command now is
followed byCode:g++ -shared -Wl,-soname,libmylib.so.1 -o libmylib.so.1.2.3 [other options]
creating a convenience symbolic link. this is all still in /home/user/project/lib/c++Code:ln -sfv libmylib.so.1.2.3 libmylib.so
running the same executable linking command for the "test" executable as above succeeds, but ldd shows that libmylib.so.1 cannot be found by the executable.
I ran readelf on the library, and it shows that the soname field is set correctly to libmylib.so.1. I also ran readelf on the executable and found that rpath is set correctly to /home/user/project/lib/c++.
I really don't know what to do now. I have had my share of pain when I was working out how the whole dynamic linking system works before, but this is something I cannot understand.
Any help would be greatly appreciated
- 11-12-2009 #2
This is probably knit-picking but is this line correct "libmylib.so -o libmylib.so". Just a posting typo?
Code:g++ -shared -Wl,-soname,libmylib.so -o libmylib.so [other otpions]
Make mine Arch Linux
- 11-12-2009 #3Just Joined!
- Join Date
- Nov 2009
- Posts
- 2
- 11-13-2009 #4Linux Engineer
- Join Date
- Apr 2006
- Location
- Saint Paul, MN, USA / CentOS, Debian, Solaris, SuSE
- Posts
- 1,117
Hi.
A long shot: I notice that you are using
man ld says that the form for supplying the soname isCode:-Wl,-soname,libmylib.so.1
not with a comma, but I have not tried either one personally ... cheers, drlCode:-soname=name
Welcome - get the most out of the forum by reading forum basics and guidelines: click here.
90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
We look forward to helping you with the challenge of the other 10%.
( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )


Reply With Quote
