Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I've always wondered how games handle libraries. What if you want to use a dynamic library in a game, let's say OpenGL.

You could just put it inside the /lib folder on Linux(-like), and have everything working properly; even better, on Debian systems you could just set it as a dependency. How does this work on Windows? There is no clear /lib directory, where do you put it?

Obviously you cannot ask the user to manually install the libraries. Do you simply create a folder for it somewhere, and add that to the PATH environment variable? Do you first check where other programs might have put it? Is there a 'standard' to do this?

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

Regarding your example, OpenGL is always dynamically linked because its implementation is provided by the graphics card manufacturer, so each time OpenGL is patched you don't need to rebuild/re-link all the applications. OpenGL on windows is installed when you install the Graphics Card Driver like Nvidia, or ATI, and the OpenG32.dll is usually installed in system32 folder so every application can dynamically link to it.

Regrading other libraries, the best practice is to let the installer put the libraries inside the game directory with your executable, so your executable can see them. Other options is to install them in system32 but this is BAD, because you will spread your files everywhere in the user's PC, and consequently the user will hate you.

Keep in mind that windows only look at the directories that are defined in the environment variable Path and the current active directory which is usually the game exe dir. If the libs where somewhere in the directory tree of the game you need to explicitly tell them (depending on how you link) the link library to load ./Core/X.dll

Here is a screen shot from my PC (running Windows 8), for Battlefield 3 directory, clearly the game is using Qt libraries and is installing them inside the games directory. Notice that BF3.exe is one level higher than Qt libs namely in Battlefield 3 Dir. This is only one way to structure your applications libraries.

enter image description here

share|improve this answer
    
Does Windows actually look inside sub-directories when looking for the DLLs? –  Jeroen Bollen Dec 7 '13 at 15:39
    
@JeroenBollen I edited the answer –  concept3d Dec 7 '13 at 15:47
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.