nanobind_example icon indicating copy to clipboard operation
nanobind_example copied to clipboard

ImportError: DLL load failed while importing nanobind_example_ext: Le module spécifié est introuvable.

Open T4mmi opened this issue 10 months ago • 1 comments

Hi, thanks for py/nano binds ! I'm facing problems on my machine (Windows + MinGW) building valid extensions ... yet I am able to compile pure C++ Ok :

#include <iostream>
using namespace std;
int main() {
    cout << "Hello World";
    return 0;
}
g++ hello.cpp -o hello.exe
hello.exe
> Hello World

build this example runs smoothly, no errors, no warnings ... nanobind_example_ext.pyd is generated ok ... but importing it or from it leads to an ImportError:

----> 1 from .nanobind_example_ext import add, __doc__

ImportError: DLL load failed while importing nanobind_example_ext: Le module spécifié est introuvable.

I tried to investigate the extension using dependencies walker ... it lacks QueryOOBESupport, ext-ms-win-oobe-query-l1-1-0.dll BUT this has been reported as a false alarm ... I'm a bit confused on where / how to fix this :s

  • https://github.com/lucasg/Dependencies/issues/220
  • https://learn.microsoft.com/en-us/answers/questions/1195445/kernel32-dll-dependenci-ext-ms-win-oobe-query-l1-1) Image

T4mmi avatar Feb 28 '25 10:02 T4mmi

Oh and I've got the exact same problem on multiple projects :(

T4mmi avatar Feb 28 '25 10:02 T4mmi

Same problem, did you fix it?

test3211234 avatar Sep 29 '25 22:09 test3211234

Oh, sorry my bad i didn't follow up the issue ...
Yes we did ! it was a CMAKE configuration issue on our side, we had to staticaly link the std libs !

For those who encounter the same issue, adding the following line to the CMakeLists.txt, should fix it:

# link c/c++ stl statically
target_link_options(${CMAKE_PROJECT_NAME} PRIVATE -static-libgcc
                    -static-libstdc++)

T4mmi avatar Sep 30 '25 11:09 T4mmi

I could add it to the CMakeLists.txt of this project to prevent the error from happening for Windows/MinGW users ... if you think it's relevant ... just tell

T4mmi avatar Sep 30 '25 11:09 T4mmi