3

I am trying to convert my python module from .py to .pyd dll.

Every time I tried to excute my setup script.

from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext
ext_modules = [
    Extension("core",  ["core.py"]),
]

setup(
    name = 'core',
    cmdclass = {'build_ext': build_ext},
    ext_modules = ext_modules
)

I get this error:

c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: cannot find -lvcruntime140.dll
collect2.exe: error: ld returned 1 exit status
error: command 'C:\\MinGW\\bin\\gcc.exe' failed with exit status 1
Charles Duffy
  • 280,126
  • 43
  • 390
  • 441
  • 3
    That's a *VStudio 2015* lib. You should install it and use it to build the *pyd*, if you'r going to use it with *Win* *Python*. https://stackoverflow.com/questions/45340527/how-to-circumvent-windows-universal-crt-headers-dependency-on-vcruntime-h. – CristiFati Oct 01 '19 at 10:40
  • BTW, as it says, that error is from `ld` -- the linker gcc starts after it's finished creating object files -- not gcc itself. – Charles Duffy Oct 09 '19 at 18:08

1 Answers1

0

My problem was solved using these commands:

  • Converting my script to C code via cython:

cython -3 main.py

  • Using gcc directly to convert .c to .pyd dll:

gcc main.c -o main.pyd -shared -IC:\Python36\include -LC:\Python36\libs -lpython36