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

Author Topic: How can I not put the .dll files and the .exe file in the same directory??  (Read 3685 times)

0 Members and 1 Guest are viewing this topic.

TraverseBiTree

  • Newbie
  • *
  • Posts: 11
    • View Profile
    • Email
When I compile a project linked to the dynamic version of SFML , I must put the SFML DLLs with the same directory with .EXE file .Like this:




But I don't want them in the same directory and I don't want to set environment for these DLLs. How can I do that??

   

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
You can't.
Laurent Gomila - SFML developer

kojack

  • Sr. Member
  • ****
  • Posts: 342
  • C++/C# game dev teacher.
    • View Profile
The easiest way would be to use a static build of sfml. But you explicitly said the dynamic build so I guess that's not an option.

Otherwise it's tricky to change DLL search.
DLLs are either load time linked (happens automatically on program start, such as with sfml's libs) or run time linked (you have to manually load each library and search for functions inside of it one by one)
Run time linked dlls are specified with a file path, so you can load them from anywhere.
Load time linked dlls have fixed locations that are searched (the system path, the working directory, the directory of the exe, etc).

The path used can be changed using SetDllDirectory, but your main function happens after load time linking.
I think setting your app to delayload the dlls (it's an option in the project's linker settings, it makes dlls not get loaded until the first time a function in them is called) might work with SetDllDirectory, but sfml's graphics library is incompatible with delayload (just tested, something with Color upset the linker), so that doesn't work.

TraverseBiTree

  • Newbie
  • *
  • Posts: 11
    • View Profile
    • Email
Thank you very much. I got it. ;D

 

anything