1

I am trying to build a source using python's distutils. I have created a simple setup.py following an example, and building it as suggested works fine:

python setup.py build

Now it is possible to build a source with a desired compiler; a list of compilers can be found as

python setup.py build_ext --inplace --help-compiler
List of available compilers:
  --compiler=bcpp     Borland C++ Compiler
  --compiler=cygwin   Cygwin port of GNU C Compiler for Win32
  --compiler=emx      EMX port of GNU C Compiler for OS/2
  --compiler=mingw32  Mingw32 port of GNU C Compiler for Win32
  --compiler=msvc     Microsoft Visual C++
  --compiler=unix     standard UNIX-style compiler

However, if I try to use, for example, the mingw32 compiler as follows

python setup.py build --compiler=mingw32

I get the following error output:

building 'demo' extension
creating build
creating build/temp.linux-i686-2.7
gcc -mno-cygwin -mdll -O -Wall -DMAJOR_VERSION=1 -DMINOR_VERSION=0 -I/usr/local/include -I/usr/include/python2.7 -c demo.c -o build/temp.linux-i686-2.7/demo.o
cc1: error: unrecognized command line option ‘-mno-cygwin’
cc1: error: unrecognized command line option ‘-mdll’
error: command 'gcc' failed with exit status 1

What is the cause for this problem? Am I doing something wrong? Do I need to specify something else? Am I using wrong versions (Ubuntu 12.04, python 2.7.3, Distutils 1.0a4)?Do I need to 'remove' the offending options?

4

2 回答 2

0

你能尝试安装 python 开发头文件然后运行你的命令吗?

sudo apt-get install python-dev
sudo apt-get install libevent-dev
于 2013-07-05T13:12:22.267 回答
0

我不认为你在 Ubuntu 上真的有 MinGW。

正如你已经引用的那样,

--compiler=mingw32  Mingw32 port of GNU C Compiler for Win32

你应该试试--compiler=unix

于 2013-07-05T12:53:54.623 回答