Categories
木有技术

Windows 下使用MinGW编译Cython

用Visual C++编译器也是可以的(找不到vcvarsall.bat可以看这篇),不过为了后面移植方便,目前的项目还是用MinGW.
步骤其实很简单,参考http://cython.readthedocs.io/en/latest/src/tutorial/appendix.html
稍微翻译一下就是:

  1. 从这里http://www.mingw.org/wiki/HOWTO_Install_the_MinGW_GCC_Compiler_Suite 下载个MinGW Installer. 下载、安装的时候记住是32位版本的,因为64位版仍旧有些不兼容现象。
  2. 运行安装下载的程序。Cython只需要最基本的包(basic package)就行了,主要是为了里面的C++编译器
  3. 将你安装MinGW的目录设置到PATH环境变量中。默认位置应该是C:\MinGW\bin
  4. 在Python安装目录下创建配置文件。如果Python是安装在C:\Python27目录下,那就创建C:\Python27\Lib\distutils\distutils.cfg,然后文件内容为
    [build]
    compiler = mingw32

     

这样就可以使用GCC编译啦~
 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.