I'm using Glibmm on Linux for my project, which needs to load plugins and execute functions from within those. However, I was having problems with it never finding the symbol I was after. Given that the project is somewhat complicated, I made a simple test-case, but even then it failed to find the symbol.
Here's the test-case program:
int main(int argc, char **argv)
//Load a module from the argument given to the program.
Glib::Module *test = new Glib::Module(std::string(argv));
//Log an error if the module fails to load.
if(!test) std::cout << Glib::Module::get_last_error() << std::endl;
//Here's out function pointer.
void (*testptr)() = NULL;
//Here's our problem. From what I can tell, this should load the symbol into testptr. What actually happens is that the symbol is 'undefined' according to Glib.
if(!test->get_symbol(std::string("test"), (void *&)testptr)) std::cout << Glib::Module::get_last_error() << std::endl;
..and here's the test-case module:
//NOTE: I know there should be a G_MODULE_EXPORT here, but a) I couldn't find the C++ equivalent, and b) the manual says it's a no-op on *nix, so it shouldn't matter anyway.
Perhaps somebody can tell me what I'm doing wrong?
Feedback on code style/Glibmm idioms is also appreciated.