如何使用 Visual Studio 编译器在 Windows 上编译 cython 编译的 c 代码

How to compile cython-compiled c code on Windows using Visual Studio Compilers

我想用 cython 编译我的 python 代码。 在cython中编译我的代码没有问题,但我无法将其编译为可执行文件。

cl .\setup.c /I C:\Users\Host\AppData\Local\Programs\Python\Python37\include

我得到的错误是

/out:setup.exe
setup.obj
LINK : fatal error LNK1104: cannot open file 'python37.lib'

我正在使用 Windows 10 和 python 3.7

的 64 位版本

非常感谢。

LNK1104 表示链接器无法在 LIB 环境中设置的默认路径中找到 python37.lib

要更正此问题,需要将 python37.lib 的目录添加到传递给链接器的库搜索路径中。给定发布的命令行,这很可能是:

cl .\setup.c /I "C:\Users\Host\AppData\Local\Programs\Python\Python37\include" /link /LIBPATH:"C:\Users\Host\AppData\Local\Programs\Python\Python37\libs"