User forums > Using Code::Blocks
Shared Library and rpath
edwin:
Hello,
If I may, I would like to ask for some input regarding the usage of rpath and CodeBlocks.
I have gone through all the rpath related posts on the C::B forum and many other locations via Google (stackoverflow, etc).
I found much information but I am still having issues using rpath in my project build options. I am posting to this support forum after 1.5 days of not figuring this out. :(
Summary:
rpath can be used as a linker option. It is used to add additional search paths to a binary executable. In my case, I need to have my main console app and the shared lib in the same directory regardless of my build directory structure.
Some Specifics:
I have an executable “driver program” and shared lib (both for Linux and Mac OS X). The shared lib is built to a common directory. The main console app then links to the shared *.so lib. The main executable binary image is also output to the common directory that holds the shared lib.
I want to be able to run the main console app within the C::B/debugger IDE and also from a console window using the command line. I am developing on Ubuntu 9.10 and Mac OS X 10.6.3.
On Ubuntu, I am using:
g++ (4.4.1)
ld (2.20)
On Mac OS X 10.6.3:
g++ (4.2.1)
ld (ld64-97.2)
I have tried many variants of using rpath in my C::B build options but I am at a loss why I can't seem to get this to work.
Thank you in advance for any assistance. Code blocks is great!
Thank you,
edwin
Jenna:
Add
--- Code: ----Wl,-rpath=.
--- End code ---
to the "Other linker settings:" in the targets (or projects) "Linker settings".
edwin:
Thank you jens. I will try it out immediately on Linux and Mac and report back.
Super!!! :)
edwin:
Hello jens,
Please excuse the delay of this post… I got side tracked with another task. Grrrr….
I must be doing something really dumb for I still can’t get this to work. :(
I understand your last post and updated my build project for the main executable “driver” app as you stated.
I am focusing on the Linux debug build of my code at the moment. I am testing the build by running the main executable under the debugger using the C::B IDE. The build of the main executable and my shared lib complete with no errors or warnings. When I attempt to start the debug build of the main executable by pressing F8, the debugger log in C::B generates the gdb message:
Program exited with code 0177.
…and the main executable fails to start.
My main executable and shared library are all built to the same target directory and C::B is set up to have the “execution working dir” set to the exact same dir of those binary images.
Also, I tried different combinations of how to specify the main executable links to the shared lib. I used a complete relative path to the shared lib for one of my tests. This build completed – no errors but running the main app in the IDE under the debugger or in a console window fails (cannot open shared object file: No such file or directory).
Then I use just the name of the shared lib while also specifying a separate “linker search path”. In this case, the build fails because for some reason the shared lib cannot be found during the build process.
Hmmm…. strange.
If you or anyone else could assist me further, I would be very grateful. I can post any other information you think will help.
I am using C::B SVN 6336 I built myself.
Thank you,
edwin
edwin:
One other piece of information:
The main executable is called: PortingLayerTest
The shared lib is called: TestDll.so
When I execute this command from the shell:
readelf -d PortingLayerTest
I get this:
--------------------------------------------------------------------
Dynamic section at offset 0x4dee0 contains 29 entries:
Tag Type Name/Value
0x00000001 (NEEDED) Shared library: [librt.so.1]
0x00000001 (NEEDED) Shared library: [libdl.so.2]
0x00000001 (NEEDED) Shared library: [bin/DebugLinux32/TestDll.so]
0x00000001 (NEEDED) Shared library: [libstdc++.so.6]
0x00000001 (NEEDED) Shared library: [libm.so.6]
0x00000001 (NEEDED) Shared library: [libgcc_s.so.1]
0x00000001 (NEEDED) Shared library: [libpthread.so.0]
0x00000001 (NEEDED) Shared library: [libc.so.6]
0x0000000f (RPATH) Library rpath: [.]
0x0000000c (INIT) 0x804ab1c
0x0000000d (FINI) 0x807df9c
0x00000004 (HASH) 0x80481ac
0x6ffffef5 (GNU_HASH) 0x804880c
0x00000005 (STRTAB) 0x80495fc
0x00000006 (SYMTAB) 0x80488ec
0x0000000a (STRSZ) 3051 (bytes)
0x0000000b (SYMENT) 16 (bytes)
0x00000015 (DEBUG) 0x0
0x00000003 (PLTGOT) 0x8095ff4
0x00000002 (PLTRELSZ) 1472 (bytes)
0x00000014 (PLTREL) REL
0x00000017 (JMPREL) 0x804a55c
0x00000011 (REL) 0x804a52c
0x00000012 (RELSZ) 48 (bytes)
0x00000013 (RELENT) 8 (bytes)
0x6ffffffe (VERNEED) 0x804a38c
0x6fffffff (VERNEEDNUM) 7
0x6ffffff0 (VERSYM) 0x804a1e8
0x00000000 (NULL) 0x0
--------------------------------------------------------------------
I can see the rpath entry as I would expect.
It looks like the “bin/DebugLinux32/TestDll.so” entry is the issue. Looks like it should not have the relative path specified and simply be “TestDll.so”.
Yes???
Thank you,
edwin
Navigation
[0] Message Index
[#] Next page
Go to full version