# OpenGL Can i use the .DLLs in different locations?

This topic is 2918 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

So i go to school with my game, and i cant run it because the computer does not have OpenAL.dll, but its in he same place as OpenGL.dll, so i decided to move it into my project's files. under stuff, there is a include folder, and a lib folder, in which in Code::Blocks i went into "Search Directory", then as "Compiler" i put down the include file, then in the "Linker" part, i put the lib file. The include files obviously holds all the header files, and the lib folder holds all the .libs and .dlls. i dont know if im using MY librarys or MY COMPUTER'S librarys. what should i do?

##### Share on other sites
The following may help:
http://msdn.microsoft.com/en-us/library/7d83bc18(v=vs.80).aspx

Windows searches your current directory first, then elsewhere. So put them in the working directory of your application for simplicity.

##### Share on other sites
So if the computer doesnt have it, if i keep it in a different folder, it will not find them, but if i put it in the .exe directory, it will work? and what is the function name?

Oh! like when you use #include <GL/gl.h>

it will automaticly use the first .dll it finds?

##### Share on other sites
What do you mean by “function name”?
It is called “search paths”. There is no function or code involved. Just put it in the same directory as your .EXE and Windows® does the rest.

L. Spiro

##### Share on other sites

So if the computer doesnt have it, if i keep it in a different folder, it will not find them, but if i put it in the .exe directory, it will work? and what is the function name?

Oh! like when you use #include <GL/gl.h>

it will automaticly use the first .dll it finds?

Not quite. When the program requests a DLL to be loaded, it just gives the OS the name of the DLL. The OS will then search for that DLL, starting with the folder the .exe is in, then the current working directory, then the Window system directory, then the Windows directory, and finally, the directories in the PATH environment variable. If you put the OpenAL.dll in the same folder as the .exe, Windows will see that your program wants to load the DLL and then will begin to search for it. Because it searches the folder the .exe is in first, it will find it, and then it will stop searching (meaning it won't check the current working directory, then the Windows system directory, etc.) because it's found it, and load it.

##### Share on other sites
Oh, that makes sense! its like SDL librarys. thanks! So i wouldnt be able to tell where too look for the .dlls? like in the folder with the .exe, "stuff/DLL/" with all the stuff here...?

##### Share on other sites
If they are your DLL's, then you can load them how you want, what the code does that you are using is something like this:
Since you don't get too call LoadLibrary() and pass in a directory, SDL is assuming it will be relative to exe path, because they cant know what directories you have.
They call this in SDL_init() or whatever init() function SDL will use. It is grabbing functions out of a dll.

So if you wrote the DLL yourself, then yes you could call LoadLibrary("DLL/system.dll")

This is what the init() function of SDL will look like.
 HINSTANCE hLib = LoadLibrary("system.dll"); if(hLib==NULL) { cout << "Error! Can't open dll!"; return 1; } char dllpath[70]; GetModuleFileName((HMODULE)hLib,(LPTSTR)dllpath,70); cout << "Dll loaded:" << dllpath << endl; SDL_DO_STUFF1 = (pfunc1)GetProcAddress((HMODULE)hLib, "SDL_DO_STUFF1"); SDL_DO_STUFF2 = (pfunc2)GetProcAddress((HMODULE)hLib, "SDL_DO_STUFF2"); if((SDL_DO_STUFF1==NULL) || (SDL_DO_STUFF2==NULL)) { cout << "Critical error! Can't load functions !" << endl; FreeLibrary((HMODULE)hLib); return 1; } SDL_DO_STUFF1(); SDL_DO_STUFF2(); FreeLibrary((HMODULE)hLib); 

##### Share on other sites
So i have to load every function by hand? DX Thats alot for OpenGL....

• ### Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 16
• 15
• 9
• 11
• 15