我尝试编译并在我的 linux 机器上得到了同样的错误:
$ python setup.py build
DBG> include = ['/usr/include', '/usr/include/python2.6', '/usr/include/SDL']
running build
running build_ext
building 'surfutils' extension
creating build
creating build/temp.linux-i686-2.6
creating build/temp.linux-i686-2.6/src
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include -I/usr/include/python2.6 -I/usr/include/SDL -I/usr/include/python2.6 -c src/surfutils.c -o build/temp.linux-i686-2.6/src/surfutils.o
In file included from src/surfutils.c:1:
/usr/include/python2.6/pygame/pygame.h:68:17: error: SDL.h: Arquivo ou diretório inexistente
In file included from src/surfutils.c:1:
/usr/include/python2.6/pygame/pygame.h:312: error: expected specifier-qualifier-list before ‘SDL_VideoInfo’
/usr/include/python2.6/pygame/pygame.h:350: error: expected specifier-qualifier-list before ‘SDL_Surface’
src/surfutils.c:5: error: expected ‘)’ before ‘*’ token
src/surfutils.c: In function ‘PyCollisionPoint’:
src/surfutils.c:74: error: ‘SDL_Surface’ undeclared (first use in this function)
src/surfutils.c:74: error: (Each undeclared identifier is reported only once
src/surfutils.c:74: error: for each function it appears in.)
src/surfutils.c:74: error: ‘surf1’ undeclared (first use in this function)
src/surfutils.c:74: error: ‘surf2’ undeclared (first use in this function)
src/surfutils.c:74: warning: left-hand operand of comma expression has no effect
src/surfutils.c:92: error: ‘PySurfaceObject’ has no member named ‘surf’
src/surfutils.c:97: error: ‘SDL_SRCALPHA’ undeclared (first use in this function)
src/surfutils.c:111: error: ‘PySurfaceObject’ has no member named ‘surf’
src/surfutils.c:161: warning: implicit declaration of function ‘collisionPoint’
error: command 'gcc' failed with exit status 1
似乎它试图编译一个名为的扩展surfutils
,它需要 SDL 开发头文件。
所以我libsdl1.2-dev
使用我的分发包管理器安装了这个包,它工作得很好。您必须安装 SDL 开发头文件才能为您的系统构建它。
所以你的问题真的是:如何在 Windows 上安装 SDL 开发头文件,以及如何让程序使用它们?
好吧,我可以回答第二个问题。您必须编辑 setup.py:
#!/usr/bin/env python2.3
from distutils.core import setup, Extension
from distutils.sysconfig import get_config_vars
includes = []
includes.extend(get_config_vars('INCLUDEDIR'))
includes.extend(get_config_vars('INCLUDEPY'))
includes.append('/usr/include/SDL')
print 'DBG> include =', includes
setup(name='surfutils',
version='1.0',
ext_modules=[Extension(
'surfutils',
['src/surfutils.c'],
include_dirs=includes,
)],
)
更改第 9 行。它说:
includes.append('/usr/include/SDL')
将此路径更改为您的 SDL 标头所在的位置,即:
includes.append(r'C:\mydevelopmentheaders\SDL')
给游戏开发者留言,说明您遇到了这个问题。它可以提供一种在您的平台上查找 SDL 标头的更好方法。