Home > Back-end >  OSError: someObject.o: cannot open shared object file: No such file or directory
OSError: someObject.o: cannot open shared object file: No such file or directory

Time:02-07

I'm failing to load a shared object library with python. I've tried setting the LD_LIBRARY_PATH to where the someObject.o is located and that works when I am using non-sudo command to run the python script but when I use sudo I run into a linking error.

OSError: bbumintflib.o: cannot open shared object file: No such file or directory

Does anyone know how to link a .o file to the .so file?

using ldd, I know the .so cannot find the .o file.

>>>ldd someSharedObject.so
linux-vdso.so.1 (0x00007ffca69af000)
someObject.o => not found
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f53c96b8000)
/lib64/ld-linux-x86-64.so.2 (0x00007f53c9a57000)

Edit:

This is how I am building the object and sharedObject files

gcc -I ../include -I../../module1/include -I ../../module2/include --shared -fPIC someCFile.c -o someObject.o plat_linux.c

gcc someObject.o -shared -o someSharedObject.so

CodePudding user response:

This is your problem:

gcc -I ../include -I../../module1/include -I ../../module2/include --shared -fPIC someCFile.c -o someObject.o plat_linux.c
gcc someObject.o -shared -o someSharedObject.so

The first command produces a shared library with odd name someObject.o.
The second command links a new shared library named someSharedObject.so, which depends on someObject.o.

To fix this, do this:

gcc -I ... --shared -fPIC someCFile.c plat_linux.c -o someSharedObject.so 
  •  Tags:  
  • Related