Jump to content
  • Advertisement
Sign in to follow this  
erm1

How to Create a DLL from existing class

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

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. 
 
 
 

Share this post


Link to post
Share on other sites
Advertisement

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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!