简体   繁体   English

如何配置python cffi库使用mingw?

[英]How to configure python cffi library to use mingw?

Attempting to call cffi.FFI.verify() on windows will produce this error: 试图在Windows上调用cffi.FFI.verify()会产生以下错误:

distutils.errors.DistutilsPlatformError: Unable to find vcvarsall.bat

I want to use mingw to compile instead of msvc. 我想使用mingw编译而不是msvc。 I tried to make distutils use mingw by creating c:\\Python27\\Lib\\distutils\\distutils.cfg with 我试图通过创建c:\\ Python27 \\ Lib \\ distutils \\ distutils.cfg使distutils使用mingw

[build]
compiler = mingw32

but this doesn't seem to affect cffi, I still get vcvarsall.bat missing error. 但这似乎不影响cffi,我仍然得到vcvarsall.bat缺失错误。

So how can I make cffi use gcc/mingw (or in general other C compiler)? 那么如何让cffi使用gcc / mingw(或者一般其他的C编译器)呢?

Try to reinstall cffi, now that distutils is properly configured. 尝试重新安装cffi,现在已经正确配置了distutils。 For example using easy_install 例如,使用easy_install

easy_install cffi

Or even rebuild & install it from source using MinGW that way : 甚至可以使用MinGW从源代码重建和安装它:

cd cffi-src-dir
python setup.py config --compiler=mingw32 build --compiler=mingw32 install
cd ..

This will make sure that cffi is correctly setup for use with MinGW... I guess... 这将确保cffi正确设置为与MinGW一起使用......我猜...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM