Pygame cannot find include file "sdl.h"

I am trying to create a downloaded Python application on Windows that uses Pygame. I installed Python 2.5 and Pygame 1.7.1. I'm new to Python, but I just tried entering the name of the top-level .py file on the command line of the Windows console. (I am using Win XP Pro.)

This is the message I receive.

C: \ Python25 \ include \ pygame \ pygame.h (68): fatal error C1083: cannot open include file: 'SDL.h': no ​​such file or directory

I thought that Pygame was built on top of the SDL and that a separate SDL installation is not needed. However, I installed SDL 1.2.13 and added the SDL include folder to my% INCLUDE% environment variable. Not lucky yet.

I noticed that C: \ Python25 \ Lib \ site-packages \ pygame contains several SDL * .DLL files, but nowhere in the python tree there is no sdl.h header file. Of course, I could copy the sdl headers to the C: \ Python25 \ include \ pygame folder , but this is a nasty idea.

Does anyone know the right way to tune the situation?

EDIT: Application app "Penguin Machine" pygame .

+3
source share
2 answers

I tried compilation and got the same errors in my linux box:

$ 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

It looks like he's trying to compile an extension with a name that needs SDL development headers. surfutils

, libsdl1.2-dev, , . SDL, .

, : SDL Windows ?

, . 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 .

+3

-, , , (, "gcc -I/usr/local/include..." )). , . .

SDL , : " sdl", . , include, .

+1

Source: https://habr.com/ru/post/1707973/


All Articles