Hi All,
For the last few months I've been testing various capabilities of libtool and how it creates links between a parent application and a module (in the case of a plug-in system, etc). I've run into a snag in relation to undefined symbols, here's some sample code that gives me the error:
main.cxx
#include "testlog.hxx" #include "testuser.hxx"
static TestLog *log = NULL; static TestUser *user = NULL;
int main(int argc, char **argv) {
log = new TestLog();
user = new TestUser();void *lib_handle = NULL; void (*plugin_call)(int &);
lib_handle = dlopen("libtest.so", RTLD_NOW);
if (!lib_handle) {
log->error(dlerror());
exit(EXIT_FAILURE);
}plugin_call = (void (*)(int &))dlsym(lib_handle, "test_spawn");
if (log != NULL) delete log; if (user != NULL) delete user; }
the test.so file is compile from a test.cxx with these details:
test.cxx
#include "testlog.hxx" #include "testuser.hxx"
extern TestLog *log; extern TestUser *user;
void test_spawn(int &testint) {
if (testint > 2) {
log->error("Invalid user");
} else {
user->add(testint);
}
}When I compile everything, it all compiles as it should, but when I attempt to execute the application I get the following error:
ERROR: libtest.so: Undefined symbol "user"
when I do an nm of the parent app I get:
0804def4 D _8TestUser$total_users_ 0804def0 D _8TestUser$user_list_ 0804de7c d user
Which tells me the main executable file has the data in place, and obviously the libtest.so file does not:
U user
I originally thought that name mangling was coming into place here, but if I strip out all "user" related class objects, the "log" related objects work perfectly fine. I can not see any difference between my user class and the log class objects that could be causing this to fail.
_______________________________________________ http://lists.gnu.org/mailman/listinfo/libtool
