Hi everyone, I’m trying to run multi_cameras_auto_focus.py to focus 4 cameras on an Arducam adapter v2.2 board (4 Motorized Focus Cameras) connected to a Raspberry Pi. Running the script fails right away and it seems like a file is missing from the GitHub repo. I’m on Python 3.9 and the script is at /home/pi/RaspberryPi/Motorized_Focus_Camera/python/multi_cameras_auto_focus.py.
Line 8 does:
Arducam_vcm = CDLL(‘./lib/libarducam_vcm.so’)
Traceback:
Traceback (most recent call last):
File “/home/pi/RaspberryPi/Motorized_Focus_Camera/python/multi_cameras_auto_focus.py”, line 8, in
Arducam_vcm = CDLL(‘./lib/libarducam_vcm.so’)
File “usr/lib/python3.9/ctypes/init.py”, line 374, in init
self._handle = _dlopen(self._name, mode)
OSError: ./lib/libarducam_vcm.so: cannot open shared object file: No such files or directory
I need to get all 4 cameras focused for a data collection project. Any help appreciated.
Thanks for posting the full traceback. That OSError means the script can’t find libarducam_vcm.so in the ./lib/ directory relative to where you’re launching the script. The CDLL call specifically expects it at ./lib/libarducam_vcm.so.
If the repo you pulled didn’t actually include that file, that would explain it. I’ve sent you the lib file through private message — copy it into the ./lib/ folder under your python directory and give it another try.
Thanks, I added the file into the folder but I’m still getting the exact same error. I put libarducam_vcm.so inside ./lib/ next to the script, but it still says:
OSError: ./lib/libarducam_vcm.so: cannot open shared object file: No such files or directory
Which folder does it actually need to go in? I’m fairly new to Raspberry Pi and Python, so I might be putting it in the wrong place.
Since ./lib/ is where the script is looking, that part should be correct — the issue is more likely that the repo you downloaded was missing the correct/updated file in the first place. We updated that repository yesterday. Redownload it fresh and try again. After the fresh download, libarducam_vcm.so should already be sitting in ./lib/.
That ELFCLASS32 error means the library is a 32-bit binary being loaded on a 64-bit OS. The provided libarducam_vcm.so is compiled for a 32-bit OS, so it won’t load if your system is 64-bit.
Run uname -a to check your OS architecture. If it reports aarch64, that confirms 64-bit. The straightforward fix is to burn/reinstall the OS as 32-bit, since this lib is built for a 32-bit OS.
Is there any way to convert the file to 64-bit instead? I’d really rather keep the system 64-bit because I’m using other sensors on this Pi as well. Or is there another option to focus the 4 Arducams that doesn’t depend on this script?
There isn’t a prebuilt 64-bit version of that .so, so to keep your 64-bit OS you’d need to build it yourself. I can send you the source code through private message and you can compile it on your side for your OS — check your messages for the package.
To sum up the thread so far: the original failure was the missing libarducam_vcm.so in ./lib/, the redownloaded repo fixed that, and the remaining blocker is that the prebuilt library is 32-bit only. Compiling the source locally is the way forward if you want to stay on 64-bit.