SFML community forums

Help => General => Topic started by: MarkJohnson94 on July 21, 2014, 02:11:28 pm

Title: Placing libraries in seperate directory to executable
Post by: MarkJohnson94 on July 21, 2014, 02:11:28 pm
Hi there,

I have compiled several programs with MinGW, using command line options to link to the libraries I need, such as the sfml-system/window/graphics dlls. To then run this program I have to place these libraries, along with the libsndfile and openal libraries (as I am using audio) into the directory of the executable. I am trying to find out how I can have these libraries in a /library folder, which I can reference, so that I keep my build folder cleaner with less files lying around.

Thanks for any help,
Mark
Title: Re: Placing libraries in seperate directory to executable
Post by: Laurent on July 21, 2014, 02:27:29 pm
One thing you can do, is to run your executable from a script that also modifies the PATH environment variable to add your /library folder.

You can also link SFML statically if you don't want to be annoyed with DLLs.
Title: Re: Placing libraries in seperate directory to executable
Post by: MarkJohnson94 on July 21, 2014, 03:22:22 pm
But would I also have to ensure to remove this environment variable after the program exits though, if I want to ensure I don't end up with a large amount of path variables if I end up moving my build folder around. I am only really interested in statically linking if it means all DLLs can be statically linked, am I right in thinking the audio dlls need to be present in the folder, or is it possible to statically link them?
Title: Re: Placing libraries in seperate directory to executable
Post by: Laurent on July 21, 2014, 03:54:27 pm
Quote
But would I also have to ensure to remove this environment variable after the program exits though, if I want to ensure I don't end up with a large amount of path variables if I end up moving my build folder around.
The modification to the PATH variable is local, it is not permanent. It is valid only for whatever is launched from the script itself.

Quote
am I right in thinking the audio dlls need to be present in the folder, or is it possible to statically link them?
Nop, you can't link the 3rd-party dependencies statically due to their license.
Title: Re: Placing libraries in seperate directory to executable
Post by: Jesper Juhl on July 21, 2014, 08:40:40 pm
On Linux it's trivial to place a library in some other directory relative to your executable ( just use the -rpath linker option with $ORIGIN (http://en.sfml-dev.org/forums/index.php?topic=15501.msg110422#msg110422) ). Similar options exist on Mac and Windows but I don't recall how to right now - I'm sure Google can tell you though.