I'm using Code::Blocks to compile a shared library on Ubuntu. When I make a simple main.c file with:
void* CreateInterface()
{
int* x = (int*)malloc( sizeof( int ) );
*x = 1337;
return x;
}
This works fine and I can find the function CreateInterface with dlsym in another application. However, I want the function to create an instance of a class written in C++. I tried the following:
#include "IRender.h"
extern "C"
{
void* CreateInterface()
{
return new Flow::Render::IRender();
}
}
This compiled fine, but now my other application fails to find CreateInterface. How should I deal with this?