Problem
I am trying to link C++ with python, so I compiled a .so file via g++ (the MinGW version, so I believe it should be able to run on Windows) and then in python:
import ctypes
lib = ctypes.cdll.LoadLibrary("support.so")
I get the Error:
FileNotFoundError: Could not find module 'support.so' (or one of its dependencies). Try using the full path with constructor syntax.
I tried using the full path and using os.add_dll_directory(), but didn't help.
Environment
Python 3.8 / 3.9 both not working
The .so file is created by myself, it is compiled via g++.
I encourtered this problem first on Windows 11, and solved it by changing the winmode
in ctypes.__init__()
by the help of this answer https://stackoverflow.com/a/64472088/9249608.
However, when I copy this program and the .so file to another computer with Window 10, I cannot solve this problem by any of the above methods. I even tried adding the folder to the PATH or copying this .so file to the python folder, but it still produces the error.
Is there any way that I can know exactly which paths are being searched? I see that there are many searching modes in ctypes.__init__()
but I don't know how to output the corresponding searching paths.