Re: Swig'ed DLL not found in Windows with CMake
Ian Boyd <[email protected]> Thu, 23 Dec 2021 13:55:36 +0000
| Newsgroups | gmane.comp.programming.swig |
|---|---|
| Message-ID | <CAEofer4xZd-0-gB7FQRAP9nhGnjRQY-Xp3RL+LvCZ_F=q2p69A@mail.gmail.com> |
You should not expect to see a *.dll file - the pyd is the Python DLL. If the pyd file exists, the error you are seeing is caused by some issue that prevents tf from loading properly. Sometimes it is because other DLLs that it references are not available or are problematic. Tools like dependency walker and Process Monitor can help to identify such problems. However, I would first look at the issue you mention. I think you probably do need to build against the version of Python that you will be using at runtime. On Thu, 23 Dec 2021 at 12:26, patrick <[email protected]> wrote: > Hello, > > I am trying to build a Python module with help of Swig on Windows and > CMake. > The example I am following is similar to the LAMMPS swig interface here: > > > https://github.com/ymishin-gmu/LAMMPS-USER-PINN/blob/8c56ef94570325fc660819e4f123376515e8fba3/tools/swig/CMakeLists.txt > > swig_add_library(mymod > TYPE MODULE > LANGUAGE python > SOURCES swig/mymod.i formats/import.cc > ) > > Then I link the lib with: > > swig_link_libraries(mymod Python3::Python ${Boost_FILESYSTEM} ${Boost_SERIALIZATION_LIBRARY} ) > > > The build looks good but I am not sure if I should see a .dll which can be loaded. > > > When I try to import the lib I get: > > > (base) C:\CLionProjects\mymod\cmake-build-debug\lib>python > Python 3.9.5 (default, May 18 2021, 14:42:02) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32 > Type "help", "copyright", "credits" or "license" for more information. > >>> import mymod > Traceback (most recent call last): > File "<stdin>", line 1, in <module> > File "...lib\mymod.py", line 15, in <module> > import _mymod > ImportError: DLL load failed while importing _mymod: %1 is not a valid Win32 application. > > > What can be done to debug this? > > I see a .pyd file , is it enough, or should there be .dll ? > > How to check the library has the the right format? > > Maybe it is the Python interpreter (Anaconda) vs. the interpreter I use to build the package (from vcpkg) ? > > Thanks a lot for your help! > > Patrick > > > _______________________________________________ > Swig-user mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/swig-user > _______________________________________________ Swig-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/swig-user