I have a win 32 C++ application that has been developed using Visual studio 2010. The application has several classes and compiles to an executable. What I would like to know is how I can compile the classes as DLLs as I want to ship the application as an exe that calls dlls. When I was using Visual studio 6.0 I could do this but it was a bit tedious. Is there a better way to do this in Visual studio 2010 or how can this be accomplished in visual studio 2010.
How to Create a DLL from existing class
You need to create a new DLL project, and import your class files there.
Then in the class header do something like this
#ifdef DLL_PROJECT // Indicated we are building the dll
#define DLLEXPORT __declspec(dllexport)
#else // Building the executable
#define DLLEXPORT __declspec(dllimport)
#endif
class DLLEXPORT MyClass
{
// class defs go here
};
When you compile the DLL, your class and all its functions will be exported.
When you compile the EXE, use the same header and your class will be imported.
Check MSDN for more info.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement