Hi all.
I seem to have a problem loading a shared object, or more specificially a couple of functions in the SO. The SO loads fine, however, whenever I try to get some function pointers with dlsym it fails. Now, it *should* work, the functions are certainly there, and the equivelent code works fine in windows.
Now, just to be sure I'm not being a total twat and missing something obvious, here's the relevant code that loads the SO and attemepts to load the functions:
dll_handle = dlopen( "./simulator.so", RTLD_LAZY );
if( !dll_handle )
{
// failed to open the shared object/dll, so print an error and exit
cout<<"Fatal Error: Failed to open the simulator shared object/dll.\n";
cout<<"dlerror: "<<dlerror()<<endl;
return 0;
}
// load the functions
RetrieveSimulatorInterface = (PFNRETRIEVESIMULATORINTERFACE)dlsym( dll_handle, "RetrieveSimulatorInterface" );
DestroySimulatorInterface = (PFNDESTROYSIMULATORINTERFACE)dlsym( dll_handle, "DestroySimulatorInterface" );
if( !RetrieveSimulatorInterface ||
!DestroySimulatorInterface )
{
cout<<"Error: Cannot load the Simulator Interface retrieval/destruction functions.\n";
cout<<"dlerror: "<<dlerror()<<endl;
dlclose( dll_handle );
return 0;
}
Now, I'm compiling the SO using the following command:
g++ <source files> -shared -o simulator.so
That correct? For completeness, the executable is compiled using:
g++ <source files> -l dl -o text_interface
Oh, and these are the functions, in the SO, that I'm wishing to get pointers to:
extern "C"
{
bool RetrieveSimulatorInterface( ISimulatorManager **ptr, int version );
void DestroySimulatorInterface( ISimulatorManager **ptr );
}
dlerror is reporting this on failure:
"./text_interface: undefined symbol: DestroySimulatorInterface"
Any ideas why this isn't working?
Thanks all.