Can someone offer direction to this strange
problem. I have built a 4 line function and built it into a shared
library using libtool. I call the library with dlopen() (which is
succesful), but when I call dlsym() it can't find the symbol for the
function. However, If i go into the gdb debugger and display the functions
(info functions) in the symbol table, my function is there!!! I can even
call the function in gdb (call foo(3) ).
I am on Solaris 2.6 and installed the latest linker
patch (107733-09) that did not help a thing. Does anyone know what could
possibly be happening??
Here is my libtool commands (which work
fine):
libtool gcc -g -O -c gcc001.cpp
libtool gcc -g -O -o libgcc001.la gcc001.lo -rpath /home/cjl/lang/c++/sharedLibraries/.libs -lm libtool gcc -module -o libgcc001.la gcc001.lo -rpath /home/cjl/lang/c++/sharedLibraries/.libs -lm libtool gcc -g -export-dynamic -ldl -o dlopen dlopen.cpp Here is my shared object code
(gcc001.cpp):
int myTestFunction(int x) { x = x*2; return x; } Here is my code that does the dlopen() and
dlsym():
#include <stdio.h>
#include <dlfcn.h> #include <stdio.h> int main() { void *handle; int (*fptr)(int); char* error = 0; handle = dlopen("/home/cjl/lang/c++/sharedLibraries/.libs/libgcc001.so", RTLD_NOW | RTLD_WORLD ); if(!handle) { fputs( dlerror(), stderr); exit( -1 ); } fptr = (int (*) (int) ) dlsym(handle, "myTestFunction"); char* error_msg = dlerror(); if (error_msg) { fprintf(stderr, "Error locating mytestFunction %s\n", error_msg ); dlclose(handle); exit(-1); } printf("%d\n",(*fptr)(8) ); dlclose(handle); return 0; } |
- Re: ld.so.1 can't find symbol. Christopher Lintz
- Re: ld.so.1 can't find symbol. Peter Eisentraut