![]() |
Dynamic link locally | ![]() |
![]() |
Dynamic link locally | ![]() |
Jonas Kulla
Guest
![]() |
![]() |
2014-03-22 5:12 GMT+01:00 Nairou:
If you want it to be "self-contained", why did you decide to not statically link? In any case, to get a similar behavior as on windows, build the executable with the rpath "$ORIGIN". |
||||||||||||
|
![]() |
Dynamic link locally | ![]() |
Daniel Gibson
Guest
![]() |
![]() |
Am 22.03.2014 17:56, schrieb Jonas Kulla:
Statically linking SDL on Linux sucks, because you never know which obscure sound system your users are going to use (or even going to use in 5 years), so giving the user the possibility to replace the bundled libSDL2.so.* is the Right Thing To Do. (In the past this made it possible to play old Loki ports and similar on newer distributions by replacing the libSDL with something more recent). Cheers, Daniel _______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
||||||||||||
|
![]() |
Dynamic link locally | ![]() |
Jonas Kulla
Guest
![]() |
![]() |
2014-03-22 18:09 GMT+01:00 Daniel Gibson:
Sure, if you're shipping a commercial product, that's the way to go. I assumed he just wanted to quickly let his friends try out a work-in-progress application. |
||||||||||||||
|
![]() |
Dynamic link locally | ![]() |
Ryan C. Gordon
Guest
![]() |
![]() |
When linking, make sure '-Wl,-path,$ORIGIN' is on the command line.
And try "readelf -d ./MyExeName" to make sure it worked. The '$' confuses things in some build systems. rpath $ORIGIN tells the system loader "look for shared libraries in the same directory as this binary." I use this on shipping games. --ryan.
SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
||||||||||||
|
![]() |
Dynamic link locally | ![]() |
Ryan C. Gordon
Guest
![]() |
![]() |
On 03/22/2014 06:05 PM, Ryan C. Gordon wrote:
(stupid autocorrect!) That should read '-Wl,-rpath,$ORIGIN' ... the original email said '-path', not '-rpath'. --ryan. _______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
||||||||||||
|
![]() |
![]() |
Nairou
![]() |
![]() |
Awesome, thanks!
|
||||||||||
|
![]() |
![]() |
Nairou
![]() |
![]() |
I finally had a chance to test this out, and I'm still not getting it to find the shared library file:
Here's the line from readelf:
And from ldd:
For confirmation, here's the rpath flag in my makefile:
Any further idea on what I'm not doing right? Does it matter that the build directory and the binary destination (stage) directory are different (I'm not running make from the same folder that the executable ends up in)? Does the compiler need to be able to find the .so file at link time, or is it completely deferred to run time? |
||||||||||||||||||
|
![]() |
Dynamic link locally | ![]() |
Jonas Kulla
Guest
![]() |
![]() |
2014-03-31 21:22 GMT+02:00 Nairou:
Verify the rpath entry in your exe by running readelf -d game | grep rpath |
||||||||||||
|
![]() |
Re: Dynamic link locally | ![]() |
Nairou
![]() |
![]() |
Ahh. I get nothing, no mention of rpath. |
||||||||||||
|
![]() |
Dynamic link locally | ![]() |
Jonas Kulla
Guest
![]() |
![]() |
2014-03-31 21:44 GMT+02:00 Nairou:
Can you try compiling again, with this argument form: -Wl,-rpath,\$ORIGIN (backslash added in front of '$') |
||||||||||||
|
![]() |
![]() |
Nairou
![]() |
![]() |
Okay, after editing my makefile to specify the rpath in LDFLAGS instead of CFLAGS, it shows up. However it doesn't look right (and still doesn't work):
[nairou@kharik stage]$ readelf -d ./game | grep rpath 0x000000000000000f (RPATH) Library rpath: [RIGIN] I tried adding a backslash in front (\$ORIGIN), but I got the same result... |
||||||||||
|
![]() |
Dynamic link locally | ![]() |
Daniel Gibson
Guest
![]() |
![]() |
Try something like:
-Wl,-rpath,'$$ORIGIN' (in '' and two $$) - at least that worked for me in a normal Makefile you may also have to add -Wl,-z,origin before the other thing to tell the linker you're gonna use $ORIGIN Cheers, Daniel Am 31.03.2014 22:04, schrieb Nairou:
_______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
||||||||||||
|
![]() |
Re: Dynamic link locally | ![]() |
Nairou
![]() |
![]() |
Great! Double $$ in quotes did the trick. Thanks! Caleb |
||||||||||||
|