Saturday, October 23, 2021

[SOLVED] How to fix "cannot find -lvcruntime140.dll" while compiling .py to .pyd?

Issue

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

Solution

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



Answered By - elmoiv