I’m trying to dynamically load a camera library .so file into a Linux executable to gain access to simple camera functions.
I’m attempting to do this by:
if ( (newHandle = dlopen("./libCamera.so",RTLD_LAZY | RTLD_GLOBAL)) == NULL )
{
printf( "Could not open file : %s\n", dlerror() );
return 1;
}
However this fails and I receive the following output:
“Could not open file : libCamera.so: undefined symbol: ZTVN10_cxxabiv117__class_type_infoE”
How do I find out what symbols it is relying on?
Most likely,
libCamera.souses a symbol defined in a shared library without depending on that library.Find a culprit. Take a real executable which links against
libCamera.so(and it works). List its dependencies withldd /path/to/executable. Among them should be a library which has a definition forZTVN10_cxxabiv117__class_type_infoE(usegrepto select likely candidates,nm -Don a library to be sure). That library won’t be in the list shown byldd ./libCamera.so.Solve a problem. Load the library found in step 1 by
dlopenfirst (useRTLD_GLOBALthere as well).If there is a problem with another symbol, goto step 1.
If newly-added libraries have the same problem too, goto step 1.
Tell library authors to please fix their linking.
It could also happen that one of the prerequisites in
ldd ./libCamera.sogot upgraded and lost a symbol definition (maybe it was recompiled with a compiler which does name mangling differently). Then you won’t find the culprit in step 1, and there is no solution but downgrading something again.