Jump to content
  • Advertisement
Sign in to follow this  
BennettSteele

OpenGL Can i use the .DLLs in different locations?

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!