문제

Pygame을 사용하는 Windows에서 다운로드 된 Python 앱을 구축하려고합니다. Python 2.5와 Pygame 1.7.1을 설치했습니다. 나는 Python을 처음 접했지만 Windows 콘솔 명령 줄에서 최상위 레벨 .py 파일의 이름을 입력하려고 시도했습니다. (Win XP Pro를 사용하고 있습니다.)

이것은 내가받는 메시지입니다.

C : python25 include pygame pygame.h (68) : 치명적인 오류 C1083 : 열 수 없음 파일 포함 : 'sdl.h': 그러한 파일 또는 디렉토리가 없습니다.

나는 Pygame이 SDL 위에 구축되었으며 별도의 SDL 설치가 필요하지 않다고 생각했습니다. 그럼에도 불구하고 SDL 1.2.13을 설치하고 SDL 포함 폴더를 % 포함 % 환경 변수에 추가했습니다. 여전히 운이 없습니다.

난 그것을 알아 챘다 C : python25 lib site-packages pygame 여러 sdl*.dll 파일이 포함되어 있지만 파이썬 트리의 어느 곳에도 SDL.H 헤더 파일이 없습니다. 물론 SDL 헤더를 C : python25 include pygame 폴더이지만 그것은 불쾌한 생각입니다.

물건을 설정하는 올바른 방법을 아는 사람이 있습니까?

편집하다:응용 프로그램입니다 "펭귄 머신"Pygame 앱.

도움이 되었습니까?

해결책

컴파일을 시도했고 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 개발 헤더를 설치하려면 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 헤더를 찾는 더 나은 방법을 제공 할 수 있습니다.

다른 팁

컴파일러가 여러 디렉토리에서 헤더 파일을 찾는 것을 컴파일하면 일부 하드 코딩 및 빌드 및 일반적으로 컴파일러에 대한 인수 (예 : "gcc -i/usr/local/include ...")로 제공됩니다. 한 가지 추측은 당신이 이것을 놓치고 있다는 것입니다. 다른 가능한 원인을 확인하지 않으면 오류 메시지.

당신은 필요합니다 SDL 개발 라이브러리가 설치되었지만 "SDL 헤더를 복사 할 수 있습니다"라고 말하면 이미 가지고있는 것처럼 들립니다. 그런 다음 문제는 컴파일러가 해당 파일을 포함하는 포함 디렉토리를 살펴 보도록하는 것입니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top