Everytime you install a game, DLL's are all thats in the directory, and you see no source files. I was wondering what the use of a DLL is and how I would implement one in my engine?
Thanks.
Beene
Printable View
Everytime you install a game, DLL's are all thats in the directory, and you see no source files. I was wondering what the use of a DLL is and how I would implement one in my engine?
Thanks.
Beene
You posted this kind of thing awhile ago:
http://cboard.cprogramming.com/showthread.php?t=81050
Try reading.
You create a Win32 project and specify DLL.
If you declare your classes/functions as _declspec(dllexport) then that class will be exported. If you declare your classes/functions as _declspec(dllimport) then that class will be imported.
So you want to use export in the header for creating the DLL and import when you are using the header. In order to use the same header you could do this:
If you are creating the DLL then define DLL_EXPORTS inside of your preprocessor options for your project. When you are using the DLL this will not be defined and so the classes/functions will be imported.Code:#ifdef DLL_EXPORTS
#define DLL_API __declspec(dllexport)
#else
#define DLL_API __declspec(dllimport)
#endif
class DLL_API MyClass { };
You load a DLL using LoadLibrary and then you can gain function pointers to various functions inside of the DLL. But if you want to use a class from a DLL you just do what I instructed, include the correct header, link with the import lib that was created when you made the DLL, and you can use the class just like a normal C++ class.