Hey I'm trying to write a Game-Engine and I was trying to export a class in a Dll and was trying to use it in my main code. Like using loadlibrary()
function. I know how to export and use functions to and from Dll. But I want to export classes and then use them just like I use functions. I don't want to include <headers>
for that class and then use it. I want it to be run-time. I have the following code for a very simple class that I was using to just experiment with it.
#ifndef __DLL_EXP_
#define __DLL_EXP_
#include <iostream>
#define DLL_EXPORT __declspec(dllexport)
class ISid
{
public:
virtual void msg() = 0;
};
class Sid : public ISid
{
void msg()
{
std::cout << "hkjghjgulhul..." << std::endl;
}
};
ISid DLL_EXPORT *Create()
{
return new Sid();
}
void DLL_EXPORT Destroy(ISid *instance)
{
delete instance;
}
#endif
How do I use this in my main code? Any help will be really appreciated. In case if it's important I'm on Visual Studio 2012.