放一个我编译好的http://download.csdn.net/detail/toontong/4372898
关于ujson,请看:http://simple-is-better.com/news/458
安装MinGW, 我使用mingw-get-inst-20120426.exe安装,网络安装,有时没法安装完整,下载总不稳定。
过了两天跑才下载到gcc.exe。
python版本为2.6.8, gcc.版本为version 4.6.2 (GCC)
可以运行
python setup.py build -c mingw32
第一次输出错误:
cc1.exe: error: unrecognized command line option '-mno-cygwin'
error: command 'gcc' failed with exit status 1
查了,原来是gcc的4.6的版本后去除了参数'-mno-cygwin'项,此参数项在文件:
C:\Python26\Lib\distutils\cygwinccompiler.py
中,直接修改这个文件,把几个 '-mno-cygwin'全删除。再运行:
python setup.py build -c mingw32
第二次输出错
c:\mingw\bin\../lib/gcc/mingw32/4.6.2/../../../../include/stdint.h:32:20: note:
previous declaration of 'uint32_t' was here
./python/objToJSON.c: In function 'PyLongToINT64':
./python/objToJSON.c:101:12: warning: unused variable 'obj' [-Wunused-variable]
./python/objToJSON.c: In function 'objToJSON':
./python/objToJSON.c:695:3: warning: initialization from incompatible pointer ty
pe [enabled by default]
./python/objToJSON.c:695:3: warning: (near initialization for 'encoder.beginType
Context') [enabled by default]
./python/objToJSON.c:706:3: warning: initialization from incompatible pointer ty
pe [enabled by default]
./python/objToJSON.c:706:3: warning: (near initialization for 'encoder.releaseOb
ject') [enabled by default]
./python/objToJSON.c: At top level:
./python/objToJSON.c:92:14: warning: 'PyIntToINT64' defined but not used [-Wunus
ed-function]
error: command 'gcc' failed with exit status 1
C:\MinGW\bin\gcc.exe -mdll -O -Wall -I./python -I./lib -IC:\Python26\include -IC
:\Python26\PC -c ./python/ujson.c -o build\temp.win32-2.6\Release\.\python\ujson
.o
C:\MinGW\bin\gcc.exe -mdll -O -Wall -I./python -I./lib -IC:\Python26\include -IC
:\Python26\PC -c ./python/objToJSON.c -o build\temp.win32-2.6\Release\.\python\o
bjtojson.o
In file included from ./python/objToJSON.c:4:0:
./lib/ultrajson.h:83:26: error: conflicting types for 'uint32_t'
c:\mingw\bin\../lib/gcc/mingw32/4.6.2/../../../../include/stdint.h:32:20: note:
previous declaration of 'uint32_t' was here
./python/objToJSON.c: In function 'PyLongToINT64':
./python/objToJSON.c:101:12: warning: unused variable 'obj' [-Wunused-variable]
./python/objToJSON.c: In function 'objToJSON':
./python/objToJSON.c:695:3: warning: initialization from incompatible pointer ty
pe [enabled by default]
./python/objToJSON.c:695:3: warning: (near initialization for 'encoder.beginType
Context') [enabled by default]
./python/objToJSON.c:706:3: warning: initialization from incompatible pointer ty
pe [enabled by default]
./python/objToJSON.c:706:3: warning: (near initialization for 'encoder.releaseOb
ject') [enabled by default]
./python/objToJSON.c: At top level:
./python/objToJSON.c:92:14: warning: 'PyIntToINT64' defined but not used [-Wunus
ed-function]
error: command 'gcc' failed with exit status 1
注意红色那句,类型重复定义,好吧,直接打开ultrajson.h 第83,注释//typedef unsigned __int32 uint32_t;
再编译 python setup.py build -c mingw32
C:\MinGW\bin\gcc.exe -shared -s build\temp.win32-2.6\Release\.\python\ujson.o bu
ild\temp.win32-2.6\Release\.\python\objtojson.o build\temp.win32-2.6\Release\.\p
ython\jsontoobj.o build\temp.win32-2.6\Release\.\lib\ultrajsonenc.o build\temp.w
in32-2.6\Release\.\lib\ultrajsondec.o build\temp.win32-2.6\Release\.\python\ujso
n.def -LC:\Python26\libs -LC:\Python26\PCbuild -lpython26 -lmsvcr90 -o build\lib
.win32-2.6\ujson.pyd
成功了
添加一个setup.cfg文件,内容为:
[build]
compiler = mingw32
再运行
python setup.py bdist_wininst
得到 window下的安装文件:
ujson-1.18.win32-py2.6.exe