Author Topic: Way of shipping build for linux with having .so file in the same dir?  (Read 118 times)

stephan

  • Guest
I am working on a little game, and i have implemented the BASS audio lib in it. In Windows, i just put the .dll in the same folder as the executable and works great. In linux otherwise i have to put it other folders like /usr/local/ (otherwise it will say that it cant find libbass.so; and its not the same directory for every distribution!). Is there a way of making it so it could run with the shared object in the same directory as the executable? (for linux ofcourse).

saga

  • Posts: 2624
There's two ways described in this post and the one right below it: https://www.un4seen.com/forum/?topic=8682.msg67035#msg67035
Both still apply, but modifying the rpath, if possible, is probably the better approach because it means the executable can stand on its own, without the need of a separate shells script.

stephan

  • Guest
Thank you so much! i have settled on rpath.
Added -Wl,-rpath,./ to my compiler arguments and now it picks from the current directory.
Works great

Ian @ un4seen

  • Administrator
  • Posts: 24495
I would recommend using the special $ORIGIN value in the rpath setting, eg. "-Wl,-rpath,$ORIGIN". It's a subtle difference but will allow your executable to be launched from any location, not only from within its folder. You can find an example of doing this in the MAKEFILE.IN file included in the Linux BASS package. Note the $ character can be tricky and require escaping to get it passed to the linker correctly.