Using DLL's
I was just wondering if there is a simple way to use a DLL with MSVC++ 5.0. I created a DLL with just 1 class, to test it out, but realized I didn''t know how to "link" (or whatever you do with them) it. Is there a command to suck out my class from the DLL? Something like bring_in_DLL(dll_name); The class is called TEST, and only has a constructor and destructor, and a protected "int x".
-Sponge99
"Now watch as I run away in a womanly fashion." - Batman
In order to link a class into a DLL you need to declare it with __declspec(dllexport) when linking the DLL and __declspec(dllimport) when linking the executable. ex:
A sample header file:
When compiling a DLL _DLL should be #defined and when compiling a executable _DLL should not be #defined. When linking the executable make sure that the DLL''s import library is linked as well.
A sample header file:
#ifdef _DLL#define DLLEXP __declspec(dllexport)#else#define DLLEXP __declspec(dllimport)#endifclass DLLEXP DllClass { public: DllClass(); ~DllClass(););
When compiling a DLL _DLL should be #defined and when compiling a executable _DLL should not be #defined. When linking the executable make sure that the DLL''s import library is linked as well.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement