tiridor Posted June 29, 2012 Share Posted June 29, 2012 Sorry in advance if this has been answered before, but a quick search didn't result in anything quite like my question. (using C) I've been all over the place trying to figure out how to have all of my DLL's outside of the main executable directory and came to the conclusions that I would either have to run the implib tool to import .lib files into my app or use the LoadLibrary/GetProcAddress for every engine function to make it work. Just when I was about to give up, I ran a build and successful run that according to everything I was reading, shouldn't work. #include "engine.h" int main (int argc, char** argv) { LoadLibrary(L"lib\\engine.dll"); //relative path LoadLibrary(L"lib\\newton.dll"); Initialize(); Graphics(640, 480, 0, 0, GRAPHICS_BACKBUFFER+GRAPHICS_DEPTHBUFFER); ... } **engine.cpp is also added to the project, of course These two LoadLibrary lines allow me to place the dll's anywhere I want outside of the executable (and system directories) and gives me full access to all of the core engine functions without redefining and fiddling with function pointers. My question is why does this work? Is it because Josh handles the GetProcAddress calls in "engine.h" through the cryptic defines? Maybe I just answered my own question, but I was just hoping for a response from someone who's more experienced with runtime dll loading than me. Quote Link to comment Share on other sites More sharing options...
Roland Posted June 29, 2012 Share Posted June 29, 2012 You don't have to change anything i the code. Just add the path to where your DLL's are to the Enviroment Variable PATH in your System Settings. Quote Roland Strålberg Website: https://rstralberg.com Link to comment Share on other sites More sharing options...
tiridor Posted June 29, 2012 Author Share Posted June 29, 2012 True, that was my first thought but I don't necessarily want to mess with a customer's system environment for a game. This way, I get the best of both worlds. I don't have to change any core files and I don't have to mess with system wide settings. yes/no, or am I missing something that should be obvious? It certainly wouldn't be the first time Quote Link to comment Share on other sites More sharing options...
Canardia Posted June 29, 2012 Share Posted June 29, 2012 Put your game.exe in a bin subfolder, and the dlls also. Then make a simple launcher exe in the main folder, which does a chdir("bin") and then starts the game using system("game.exe") or WinExec("game.exe"). Quote ■ Ryzen 9 ■ RX 6800M ■ 16GB ■ XF8 ■ Windows 11 ■ ■ Ultra ■ LE 2.5 ■ 3DWS 5.6 ■ Reaper ■ C/C++ ■ C# ■ Fortran 2008 ■ Story ■ ■ Homepage: https://canardia.com ■ Link to comment Share on other sites More sharing options...
Roland Posted June 29, 2012 Share Posted June 29, 2012 Or use LeBuilder to get what you need, fast and simple. Quote Roland Strålberg Website: https://rstralberg.com Link to comment Share on other sites More sharing options...
tiridor Posted June 30, 2012 Author Share Posted June 30, 2012 Thanks Roland & Metatron, I appreciate the advice but I think I'll stick to my current method I like the idea of having my dll's in a separate directory that I can change at anytime even through a config file after install if I felt so inclined (not that i would ) My interest was primarily in the 'why does this work?' aspect when it shouldn't without GetProcAddress calls all over the place. Anyway, it looks like it was a stupid question now that I have spent more time looking at the engine header. Sorry for posting without digging deeper for the answer myself. Quote Link to comment Share on other sites More sharing options...
Pixel Perfect Posted June 30, 2012 Share Posted June 30, 2012 I don't necessarily want to mess with a customer's system environment for a game. This way, I get the best of both worlds. I don't have to change any core files and I don't have to mess with system wide settings. Exactly, this is interesting. Thanks for posting tiridor. Quote Intel Core i5 2.66 GHz, Asus P7P55D, 8Gb DDR3 RAM, GTX460 1Gb DDR5, Windows 7 (x64), LE Editor, GMax, 3DWS, UU3D Pro, Texture Maker Pro, Shader Map Pro. Development language: C/C++ Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.