Access to .so libraries using dlopen () throws undefined symbol error

I am trying to dynamically load a library library .so file into a Linux executable to gain access to simple camera functions.

I am trying to do this:

  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 get the following output: "Could not open file: libCamera.so: undefined symbol: ZTVN10_cxxabiv117__class_type_infoE"

How do you know which symbols it relies on?

+5
source share
4 answers

It most likely libCamera.souses the symbol defined in the shared library, depending on that library.

  • . , libCamera.so ( ). ldd /path/to/executable. , ZTVN10_cxxabiv117__class_type_infoE ( grep , nm -D , ). , ldd ./libCamera.so.

  • . , 1, dlopen ( RTLD_GLOBAL ).

  • , 1.

  • , 1.

  • , .

, ldd ./libCamera.so (, , - ). 1, , - .

+10

ldd .

ldd libCamera.so

, , nm .

nm -DC libCamera.so
+6

. .a, .so .

( OP, ):

nm mylibrary.so | grep ZTVN10_cxxabiv117__class_type_infoE
0000ABC0 U ZTVN10_cxxabiv117__class_type_infoE

U , "undefined". demangled --demangle:

 $ nm --demangle mylibrary.so | grep 0000ABC0 
0000ABC0 U abi::class_type_info(params...)

( - ) , .

. , , (.a) (.o), :

g++ -Wl,-E -g -m32 ... -fPIC myobjects1.o myobjects2.o missing_library.a -shared -o mylibrary.so

( U):

 $ nm --demangle mylibrary.so | grep 0000ABC0 
0000ABC0 T abi::class_type_info(params...)

, , !

+2

libCamera.so . , type_infoE .

+1
source

All Articles