DLL location

This is a discussion on DLL location within the C++ Programming forums, part of the General Programming Boards category; Normally a program looks for the dlls it needs inside of whatever folder it is in. How do I make ...

  1. #1
    Slave MadCow257's Avatar
    Join Date
    Jan 2005
    Posts
    735

    DLL location

    Normally a program looks for the dlls it needs inside of whatever folder it is in. How do I make it so that it will look for my program's dependencies (such as sdl.dll, sdl_ttf.dll, etc.) inside of a folder called DLL?

    look in
    C:\Program Files\My Program\DLL
    instead of
    C:\Program Files\My Program

    IDE - MSVC 6

  2. #2
    Registered User
    Join Date
    Feb 2006
    Posts
    54
    #using "dlls\Whateveryourdllnameis.dll" ?
    just put the folder name and then a '\' before the name of your dll.
    I've never used one but that should work.

  3. #3
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,074
    I don't think it's possible. You play computer games? Look in the folder of any computer game you have installed. The DLLs are in the same folder as the executable. You'd think if there was a way, they'd probably do it.
    Sent from my iPad«

  4. #4
    Mad OnionKnight's Avatar
    Join Date
    Jan 2005
    Location
    Umeň, Sweden
    Posts
    555
    The OS(?) uses the PATH environment variable to find the DLLs so put .\DLL in PATH or similar. Not sure how to do it hardcoded.

  5. #5
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,074
    Quote Originally Posted by Doodle77
    #using "dlls\Whateveryourdllnameis.dll" ?
    just put the folder name and then a '\' before the name of your dll.
    I've never used one but that should work.
    That's not how DLLs work.

    Though thinking about it, I'm thinking if you load DLLs on the fly with LoadLibrary() you could specify a path. Not too sure on that. I'm thinking about things like web browsers with plugins. My guess is it would be significantly slower to do that, though.

    Here is a nice little article to read up on: http://www.flipcode.com/articles/art...tingdlls.shtml
    Last edited by SlyMaelstrom; 02-13-2006 at 05:16 PM.
    Sent from my iPad«

  6. #6
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    Code:
    LoadLibrary("stuff\\junk.dll");
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  7. #7
    Slave MadCow257's Avatar
    Join Date
    Jan 2005
    Posts
    735
    Thanks Sly. It seems I might be able to get away with having only SDL.h in the main folder while everything else is in a sub folder using LoadLibrary

  8. #8
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,074
    Though, if I were you, I'd still check out and see if it's slower to use LoadLibrary() than it is to compile with an import library. I have a funny feeling about it. If your DLL is really big, you might want to consider just doing it normally.
    Sent from my iPad«

  9. #9
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465

  10. #10
    chococoder
    Join Date
    Nov 2004
    Posts
    515
    using loadlibrary should make the loading of the DLL a bit slower (and maybe calling it too because it would need to do more resolving at runtime) but it's more flexible and uses less memory while the DLLs are not loaded.
    The static loading would load the DLL in memory at application startup, when one of the reasons to use DLLs in the first place can be to put rarely used bits of code outside normal program memory and loading (and unloading) them as required.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. non-MFC DLL with MFC app question.
    By Kempelen in forum Windows Programming
    Replies: 10
    Last Post: 08-20-2008, 08:11 AM
  2. dll communicating between each other
    By cloudy in forum C++ Programming
    Replies: 5
    Last Post: 06-17-2005, 03:20 AM
  3. DLL and std::string woes!
    By Magos in forum C++ Programming
    Replies: 7
    Last Post: 09-08-2004, 01:34 PM
  4. Using class with DLL
    By greg2 in forum C++ Programming
    Replies: 2
    Last Post: 09-12-2003, 06:24 AM
  5. .lib vs .h vs .dll
    By Shadow12345 in forum C++ Programming
    Replies: 13
    Last Post: 01-01-2003, 05:29 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21