【问题标题】:How to fix "cannot find -lvcruntime140.dll" while compiling .py to .pyd?如何在将 .py 编译为 .pyd 时修复“找不到 -lvcruntime140.dll”?
【发布时间】:2019-09-30 19:44:38
【问题描述】:

我正在尝试将我的 python 模块从 .py 转换为 .pyd dll。

每次我尝试执行我的设置脚本时。

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
)

我收到此错误:

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

【问题讨论】:

  • 这是一个 VStudio 2015 库。如果您打算将它与 Win Python 一起使用,您应该安装它并使用它来构建 pydstackoverflow.com/questions/45340527/….
  • 顺便说一句,正如它所说,该错误来自ld - 链接器 gcc 在完成创建目标文件后启动 - 而不是 gcc 本身。

标签: python gcc cython


【解决方案1】:

使用以下命令解决了我的问题:

  • 通过cython将我的脚本转换为C代码:

cython -3 main.py

  • 直接使用gcc将.c转换为.pyddll:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-09-25
    • 1970-01-01
    • 1970-01-01
    • 2019-11-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多