在我的previous question我描述了我们的情况:我们的开发人员将在cygwin环境中使用python而不是Windows 7 - 64位,但测试是在构建期间以及在linux上自动执行的。我们遇到了一些cygwin64的麻烦所以现在我们尝试使用python而不是cygwin32。
令人遗憾的是,在安装psycopg2期间,使用64位和32位版本的PostgreSQL 9.2会导致gcc编译错误。 32位版本安装日志:
$ pip install psycopg2
...
下载/解压缩psycopg2 下载psycopg2-2.5.1.tar.gz(684kB):已下载684kB 运行包psycopg2的setup.py egg_info
安装收集的软件包:psycopg2 运行psycopg2的setup.py安装 建立'psycopg2._psycopg'扩展 gcc -fno-strict-aliasing -ggdb -O2 -pipe -fdebug-prefix-map = / home / jt / rel / python-2.7.3-1 / python-2.7.3-1 / build = / usr / src / debug / python-2.7.3-1 -fdebug-prefix-map = / home / jt / rel / python-2.7.3-1 / python-2.7.3-1 / src / Python-2.7.3 = / usr / src / debug / python-2.7.3-1 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -DPSYCOPG_DEFAULT_PYDATETIME = 1 -DPSYCOPG_VERSION =“2.5.1(dt dec pq3 ext)” - DPG_VERSION_HEX = 0x090204 -DPSYCOPG_EXTENSIONS = 1 -DPSYCOPG_NEW_BOOLEAN = 1 -DHAVE_PQFREEMEM = 1 -I / usr / include / python2.7 -I。 -IC:/PROGRA~2/POSTGR~1/9.2/include -IC:/PROGRA~2/POSTGR~1/9.2/include/server -c psycopg / psycopgmodule.c -o build / temp.cygwin-1.7.24 -i686-2.7 / psycopg / psycopgmodule.o
In file included from ./psycopg/config.h:120:0,
from ./psycopg/psycopg.h:33,
from psycopg/psycopgmodule.c:27:
C:/PROGRA~2/POSTGR~1/9.2/include/pthread.h:307:8: error: redefinition of ‘struct timespec’
In file included from /usr/include/stdio.h:47:0,
from /usr/include/python2.7/Python.h:33,
from ./psycopg/psycopg.h:30,
from psycopg/psycopgmodule.c:27:
/usr/include/sys/types.h:130:8: note: originally defined here
In file included from ./psycopg/config.h:120:0,
from ./psycopg/psycopg.h:33,
from psycopg/psycopgmodule.c:27:
C:/PROGRA~2/POSTGR~1/9.2/include/pthread.h:571:24: error: conflicting types for ‘pthread_t’
In file included from /usr/include/sys/types.h:473:0,
from /usr/include/stdio.h:47,
from /usr/include/python2.7/Python.h:33,
from ./psycopg/psycopg.h:30,
from psycopg/psycopgmodule.c:27:
/usr/include/cygwin/types.h:178:45: note: previous declaration of ‘pthread_t’ was here
In file included from ./psycopg/config.h:120:0,
from ./psycopg/psycopg.h:33,
from psycopg/psycopgmodule.c:27:
C:/PROGRA~2/POSTGR~1/9.2/include/pthread.h:572:34: error: conflicting types for ‘pthread_attr_t’
In file included from /usr/include/sys/types.h:473:0,
from /usr/include/stdio.h:47,
from /usr/include/python2.7/Python.h:33,
from ./psycopg/psycopg.h:30,
from psycopg/psycopgmodule.c:27:
/usr/include/cygwin/types.h:182:50: note: previous declaration of ‘pthread_attr_t’ was here
In file included from ./psycopg/config.h:120:0,
from ./psycopg/psycopg.h:33,
from psycopg/psycopgmodule.c:27:
C:/PROGRA~2/POSTGR~1/9.2/include/pthread.h:573:32: error: conflicting types for ‘pthread_once_t’
In file included from /usr/include/sys/types.h:473:0,
from /usr/include/stdio.h:47,
from /usr/include/python2.7/Python.h:33,
from ./psycopg/psycopg.h:30,
from psycopg/psycopgmodule.c:27:
/usr/include/cygwin/types.h:193:1: note: previous declaration of ‘pthread_once_t’ was here
In file included from ./psycopg/config.h:120:0,
from ./psycopg/psycopg.h:33,
from psycopg/psycopgmodule.c:27:
C:/PROGRA~2/POSTGR~1/9.2/include/pthread.h:574:33: error: conflicting types for ‘pthread_key_t’
In file included from /usr/include/sys/types.h:473:0,
from /usr/include/stdio.h:47,
from /usr/include/python2.7/Python.h:33,
from ./psycopg/psycopg.h:30,
from psycopg/psycopgmodule.c:27:
/usr/include/cygwin/types.h:181:49: note: previous declaration of ‘pthread_key_t’ was here
In file included from ./psycopg/config.h:120:0,
from ./psycopg/psycopg.h:33,
from psycopg/psycopgmodule.c:27:
C:/PROGRA~2/POSTGR~1/9.2/include/pthread.h:575:35: error: conflicting types for ‘pthread_mutex_t’
In file included from /usr/include/sys/types.h:473:0,
from /usr/include/stdio.h:47,
from /usr/include/python2.7/Python.h:33,
from ./psycopg/psycopg.h:30,
from psycopg/psycopgmodule.c:27:
/usr/include/cygwin/types.h:179:51: note: previous declaration of ‘pthread_mutex_t’ was here
In file included from ./psycopg/config.h:120:0,
from ./psycopg/psycopg.h:33,
from psycopg/psycopgmodule.c:27:
C:/PROGRA~2/POSTGR~1/9.2/include/pthread.h:576:39: error: conflicting types for ‘pthread_mutexattr_t’
In file included from /usr/include/sys/types.h:473:0,
from /usr/include/stdio.h:47,
from /usr/include/python2.7/Python.h:33,
from ./psycopg/psycopg.h:30,
from psycopg/psycopgmodule.c:27:
/usr/include/cygwin/types.h:183:55: note: previous declaration of ‘pthread_mutexattr_t’ was here
In file included from ./psycopg/config.h:120:0,
from ./psycopg/psycopg.h:33,
from psycopg/psycopgmodule.c:27:
C:/PROGRA~2/POSTGR~1/9.2/include/pthread.h:577:34: error: conflicting types for ‘pthread_cond_t’
In file included from /usr/include/sys/types.h:473:0,
from /usr/include/stdio.h:47,
from /usr/include/python2.7/Python.h:33,
from ./psycopg/psycopg.h:30,
from psycopg/psycopgmodule.c:27:
/usr/include/cygwin/types.h:185:50: note: previous declaration of ‘pthread_cond_t’ was here
In file included from ./psycopg/config.h:120:0,
from ./psycopg/psycopg.h:33,
from psycopg/psycopgmodule.c:27:
C:/PROGRA~2/POSTGR~1/9.2/include/pthread.h:578:38: error: conflicting types for ‘pthread_condattr_t’
In file included from /usr/include/sys/types.h:473:0,
from /usr/include/stdio.h:47,
from /usr/include/python2.7/Python.h:33,
from ./psycopg/psycopg.h:30,
from psycopg/psycopgmodule.c:27:
/usr/include/cygwin/types.h:184:54: note: previous declaration of ‘pthread_condattr_t’ was here
In file included from ./psycopg/config.h:120:0,
from ./psycopg/psycopg.h:33,
from psycopg/psycopgmodule.c:27:
C:/PROGRA~2/POSTGR~1/9.2/include/pthread.h:580:36: error: conflicting types for ‘pthread_rwlock_t’
In file included from /usr/include/sys/types.h:473:0,
from /usr/include/stdio.h:47,
from /usr/include/python2.7/Python.h:33,
from ./psycopg/psycopg.h:30,
from psycopg/psycopgmodule.c:27:
/usr/include/cygwin/types.h:195:52: note: previous declaration of ‘pthread_rwlock_t’ was here
In file included from ./psycopg/config.h:120:0,
from ./psycopg/psycopg.h:33,
from psycopg/psycopgmodule.c:27:
C:/PROGRA~2/POSTGR~1/9.2/include/pthread.h:581:40: error: conflicting types for ‘pthread_rwlockattr_t’
In file included from /usr/include/sys/types.h:473:0,
from /usr/include/stdio.h:47,
from /usr/include/python2.7/Python.h:33,
from ./psycopg/psycopg.h:30,
from psycopg/psycopgmodule.c:27:
/usr/include/cygwin/types.h:196:56: note: previous declaration of ‘pthread_rwlockattr_t’ was here
In file included from ./psycopg/config.h:120:0,
from ./psycopg/psycopg.h:33,
from psycopg/psycopgmodule.c:27:
C:/PROGRA~2/POSTGR~1/9.2/include/pthread.h:582:38: error: conflicting types for ‘pthread_spinlock_t’
In file included from /usr/include/sys/types.h:473:0,
from /usr/include/stdio.h:47,
from /usr/include/python2.7/Python.h:33,
from ./psycopg/psycopg.h:30,
from psycopg/psycopgmodule.c:27:
/usr/include/cygwin/types.h:194:54: note: previous declaration of ‘pthread_spinlock_t’ was here
In file included from ./psycopg/config.h:120:0,
from ./psycopg/psycopg.h:33,
from psycopg/psycopgmodule.c:27:
C:/PROGRA~2/POSTGR~1/9.2/include/pthread.h:1131:31: error: conflicting types for ‘pthread_kill’
In file included from /usr/include/signal.h:5:0,
from /usr/include/time.h:138,
from /usr/include/sys/select.h:24,
from /usr/include/cygwin/sys_time.h:13,
from /usr/include/sys/time.h:61,
from /usr/include/python2.7/pyport.h:319,
from /usr/include/python2.7/Python.h:58,
from ./psycopg/psycopg.h:30,
from psycopg/psycopgmodule.c:27:
/usr/include/sys/signal.h:170:5: note: previous declaration of ‘pthread_kill’ was here
error: command 'gcc' failed with exit status 1
...
C:/PROGRA~2/POSTGR~1/9.2/include/pthread.h:1131:31:错误:'pthread_kill'的冲突类型
在/usr/include/signal.h:5:0中包含的文件中,
from /usr/include/time.h:138,
from /usr/include/sys/select.h:24,
from /usr/include/cygwin/sys_time.h:13,
from /usr/include/sys/time.h:61,
from /usr/include/python2.7/pyport.h:319,
from /usr/include/python2.7/Python.h:58,
from ./psycopg/psycopg.h:30,
from psycopg/psycopgmodule.c:27:
/usr/include/sys/signal.h:170:5:注意:先前'pthread_kill'的声明在这里 错误:命令'gcc'失败,退出状态为1
...
我们安装了cygwin安装包附带的标准Gcc和PostgreSQL库。下一步做什么?
非常感谢你提前: 乔,公众
答案 0 :(得分:1)
与PostgreSQL安装程序捆绑在一起的libpq
使用Microsoft Visual Studio作为本机Windows二进制文件进行编译。
如果从Cygwin链接到它恰好工作,这主要是运气。这不是一个好主意。你真的需要使用为Cygwin构建的libpq
和Cygwin程序。
坦率地说,我认为你最近只使用本机Windows并完全避开Cygwin会好得多。当你需要类似unix的构建系统时,你可以使用mysw编译器与msys,并且正确编写的Windows兼容代码可以很好地混合mingw和msvc编译的二进制文件。
在您的情况下,我只是install ActivePython或者我会安装stock Python build,然后安装add psycopg2 myself。