#### Archived

This topic is now archived and is closed to further replies.

# Using DLL's

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

## Recommended Posts

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

##### Share on other sites
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:
#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.

• 10
• 13
• 52
• 11
• 15