Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Placing libraries in seperate directory to executable  (Read 1213 times)

0 Members and 1 Guest are viewing this topic.

MarkJohnson94

  • Newbie
  • *
  • Posts: 20
    • View Profile
Placing libraries in seperate directory to executable
« 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

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Placing libraries in seperate directory to executable
« Reply #1 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.
Laurent Gomila - SFML developer

MarkJohnson94

  • Newbie
  • *
  • Posts: 20
    • View Profile
Re: Placing libraries in seperate directory to executable
« Reply #2 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?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Placing libraries in seperate directory to executable
« Reply #3 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.
Laurent Gomila - SFML developer

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: Placing libraries in seperate directory to executable
« Reply #4 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 ). Similar options exist on Mac and Windows but I don't recall how to right now - I'm sure Google can tell you though.

 

anything