Use my library cppcomponents at https://github.com/jbandela/cppcomponents
This is tested with Visual C++ 2013 (Previous versions did not have enough c++11 support) and mingw gcc 4.7+ on windows. It is a header only library released under the boost license. This allows you to use c++11 features like std::string, vector, tuple, pair, time_point across the compilers. I would be happy to answer any questions you have regarding how to use it for your particular case.
Here is an example for your case
First define the class in Window.h
#include <cppcomponents/cppcomponents.hpp>
namespace mylib{
struct IWindow :cppcomponents::define_interface<
cppcomponents::uuid<0x0d02ac9a, 0x4188, 0x48fc, 0x8054, 0xafe7252ec188 >>
{
std::string getTitle();
void setTitle(std::string new_title);
CPPCOMPONENTS_CONSTRUCT(IWindow, getTitle, setTitle);
};
inline std::string WindowID(){ return "windowlibdll!Window"; }
typedef cppcomponents::runtime_class<WindowID, cppcomponents::object_interfaces<IWindow>> Window_t;
typedef cppcomponents::use_runtime_class<Window_t> Window;
}
Then implement the class in WindowImp.cpp
#include "Window.h"
struct ImplementWindow:cppcomponents::implement_runtime_class<ImplementWindow,mylib::Window_t>
{
std::string title_;
ImplementWindow(){}
std::string getTitle(){
return title_;
}
void setTitle(std::string new_title){
title_ = new_title;
}
};
CPPCOMPONENTS_DEFINE_FACTORY()
Finally Use the code in UseWindow.cpp
#include "Window.h"
#include <iostream>
int main(){
mylib::Window w;
w.setTitle("my title");
std::cout << w.getTitle();
}
Here is how you build it the library using g++
g++ WindowImp.cpp -std=c++11 -shared -o windowlibdll.dll -I Source\Repos\cppcomponents
And here is how you build with program using MSVC 2013
cl UseWindow.cpp /EHsc /I Source\Repos\cppcomponents
Replace Source\Repose\cppcomponents
with the path were you have cppcomponents
Make sure the resulting windowslibdll.dll and the UseWindow.exe are in the same directory and run UseWindow.exe