So I was trying to learn Pybind11 with a simple project, but like always, something went wrong and I ran into this error when trying to import the module itself though the Python Shell or File.
Код: Выделить всё
ImportError: DLL load failed while importing test_module: The specified module could not be found.
The pybind Module itself includes a function that prints "Hello World".
Код: Выделить всё
#include #include void sayHello() { std::cout >> import os >>> os.add_dll_directory("C:\\MinGW\\bin") # The path where DLLs the customized pybind module needs are locating. >>> import example >>> example.add(1, 2) 3
The Main Issue.
While the solution does work, there's still one problem. It's not really portable. While my DLL directory is located at: "C:/msys64/mingw64/bin", not everyone is gonna have their's located at the same place. Yet alone even have mingw64.
The module would only work for my computer. What if I want to distribute what I'm making? If anyone else wants to use it, they would have to edit the code themselves for download something they wouldn't want to.
The only way I could see of fixing the issue is finding the DLLs the module is missing, and statically link them to the module binary itself. That way, no one has to deal with the add_dll_directory nonsense.
I tried tracking down what DLLs could be missing by using a dependency walker, but the only clue I could find on what it could be is: "ext-ms-win-oobe-query-l1-1-0.dll". However I think that clue is irrelevant as the module imports just fine when I added the DLL directory in test.py. So I could only deduce that whatever DLL the module was missing is in that directory.
Like I said, I'm frustrated that I seem to be the one of the only people who seem to be having this issue. I was wondering if any of y'all had a solution to my problem.
Источник: https://stackoverflow.com/questions/781 ... -dll-error