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

Author Topic: Change DLL path ?  (Read 12478 times)

0 Members and 1 Guest are viewing this topic.

themoder

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
Change DLL path ?
« on: August 14, 2012, 12:11:53 am »
Hi,

I would like to know if it's possible to move sfml dll away from .exe, e.g into a folder Engine, or anything.

Thanks :)

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Change DLL path ?
« Reply #1 on: August 14, 2012, 12:21:42 am »
No this is not directly possible.
One way to achive this, is to add that folder "Engine" to your PATH enviroment varible, for development this may work but for distribution it doesn't...
Another is to change the working directory of your application, afaik this can only be done from outside of the application (e.g. creating a link and chaning the working directory to the "Engine" folder.
If you just don't want the DLL file in the main folder (for some reason) you could write a starter application which you put in the main folder which then starts the real application that is located next to the dlls, but you'll also have to set the working directory correctly.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

themoder

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
Re: Change DLL path ?
« Reply #2 on: August 14, 2012, 12:51:49 am »
thanks :) I think I'll just keep them there, will be more simple ;)


Qix

  • Full Member
  • ***
  • Posts: 139
  • I am Qix!
    • View Profile
    • Natoga Technologies
Re: Change DLL path ?
« Reply #4 on: October 20, 2012, 10:07:24 am »
As the above link suggests, set up delayed loading (thought I've tried with SFML DLL's unsuccessfully, however you might be able to get them to work) and on windows you can use SetDLLDirectory (or AddDLLDirectory, depending) to add the DLL path.

Then, when your programs makes the first call to a function located in one of the delay loaded DLLs, it will attempt to load the library (instead of loading them upon startup).

However, not sure of a cross-platform solution (not too familiar with GCC); you might consider symbolic links or junctions, though they're not much better than having the DLLs in their own directory.
~ Qix
Creator of Rippl Studio
Code: [Select]
<danharibo> iostream: I don't do enough drugs to think that's a good idea.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Change DLL path ?
« Reply #5 on: October 20, 2012, 01:21:12 pm »
http://stackoverflow.com/questions/327093/add-custom-dll-search-path-application-startup
As the above link suggests, set up delayed loading (thought I've tried with SFML DLL's unsuccessfully, however you might be able to get them to work) and on windows you can use SetDLLDirectory (or AddDLLDirectory, depending) to add the DLL path.
I strongly advise against such handling of DLLs, mostly because I this is very, very, very platform specific and one should always try to keep things as cross-platform as possible, specially when it comes to the building process. The purpose of code is to execute a task/game/etc. but it's definitely not its task to tell how things are linked (same argument against #pragma comment).

Also I think the suggested ways go way too far as for what the OP has asked... :-\
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Qix

  • Full Member
  • ***
  • Posts: 139
  • I am Qix!
    • View Profile
    • Natoga Technologies
Re: Change DLL path ?
« Reply #6 on: October 21, 2012, 10:02:06 am »
http://stackoverflow.com/questions/327093/add-custom-dll-search-path-application-startup
As the above link suggests, set up delayed loading (thought I've tried with SFML DLL's unsuccessfully, however you might be able to get them to work) and on windows you can use SetDLLDirectory (or AddDLLDirectory, depending) to add the DLL path.
I strongly advise against such handling of DLLs, mostly because I this is very, very, very platform specific and one should always try to keep things as cross-platform as possible, specially when it comes to the building process. The purpose of code is to execute a task/game/etc. but it's definitely not its task to tell how things are linked (same argument against #pragma comment).

Also I think the suggested ways go way too far as for what the OP has asked... :-\

Agreed. I'm sure there is a fancy saying for it, but it sounds like you're trying to break a lot of things just to have one little luxury.
~ Qix
Creator of Rippl Studio
Code: [Select]
<danharibo> iostream: I don't do enough drugs to think that's a good idea.

cristaloleg

  • Newbie
  • *
  • Posts: 15
    • View Profile
    • Email
Re: Change DLL path ?
« Reply #7 on: October 26, 2012, 07:31:05 am »
What about static linking? Maybe in would solve the problem.

xylr117z4

  • Newbie
  • *
  • Posts: 34
    • View Profile
    • Email
Re: Change DLL path ?
« Reply #8 on: October 26, 2012, 09:39:13 pm »
What about static linking? Maybe in would solve the problem.

I'd suggest static linking but like the author said in his second post he'll just leave it because it's far more simple.