How to prevent absolute paths in dynamic linker

538 views Asked by At

I have a solution with various projects, one of which is the main executable, and the rest are libraries the executable depends on. Each one compiles and links fine. However, trying to start the executable gives weird results. Using ldd, I see that the executable is trying to find libraries like so:

../bin/debug/libBlahBlah.so => not found

However, for each project, I'm declaring "bin/debug" (which is the output directory for these libraries) as a libdirs entry, and linking against the library by adding "BlahBlah" as a link, where "BlahBlah" is the name of the project.

I'm not even sure how to accomplish this without premake. Any help is appreciated.

The original intention was to have the library sit next to the executable then set an RPATH that searched for the library next to executable. With the way it is now, it searches for that absolute path relative to the executable... I cannot figure out how to get it off.

I'm using premake5. I've tried to use the nightly and compiling myself. Upstream is currently not compiling however.

1

There are 1 answers

1
J. Perkins On BEST ANSWER

If you are using the latest alpha or source of Premake5, you can use the "RelativeLinks" flag to use -L/-l instead of relative paths to libraries:

project "MyProject"
   flags "RelativeLinks"

You will still need to set up the rpath properly though; you can do that with buildoptions() and the appropriate command line flags for your compiler. Maybe (untested):

buildoptions "-Wl,-rpath=."

That should work in Premake 4 as well.