2

I have built an .so file used in our python package. We use the package on Dietpi 64bits. When I import our package I get the error:

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

I know for a fact that the file is there and the path is good.

What is puzzling me is that when I try the same code on a Virtual Machine (also Diepi 64bit), the dynamic library is found and loaded properly. I did that to try an isolate the difference between my setup and my colleague's setup.

  • File exists
  • Same location in both cases
  • File has the same rights (chmod 777)
  • He is using python 3.6, while VM 3.7

What am I missing? What can cause the OS to raise a No such file or directory exception when the directory DOES exists and file IS there?


Edit

Here is the code that I'm using

import os
import ctypes

shared_library_name = "libFoo"

print("current working directory: {}\n".format(os.getcwd()))
current_path = str(os.path.dirname(os.path.abspath(__file__)) + "/natives/")
os.chdir(current_path)
current_path = os.path.abspath(os.getcwd())

path_to_so = os.path.abspath(current_path + "/" + shared_library_name + ".so")
print("new current_path: ", current_path)
print("\n path_to_so: {}\n".format(path_to_so))
# prints the right path with the right file, and I can cd to it in the terminal

print("path exist {}".format(os.path.isdir(current_path)))
print("file exist {}\n".format(os.path.isfile(path_to_so)))
# prints False

dll = ctypes.cdll.LoadLibrary(path_to_so)
# fails saying that the file is not there...
BaldDude
  • 1,025
  • 1
  • 19
  • 33

1 Answers1

2

The shared library that I was trying to open was not build for the architecture used by your Virtual Machine.

aarch64 vs x84_64

When I asked the question, I was not aware that my target (NanoPi Neo2) needed different flags than the virtual machine when building the shared library.

https://unix.stackexchange.com/questions/461179/what-is-the-difference-between-different-implemetation-of-arm64-aarch64-for-lin

Differences between arm64 and aarch64

BaldDude
  • 1,025
  • 1
  • 19
  • 33