[Pythonmac-SIG] Problems with PyOpenGL build and fixes?

Bill Northcott w.northcott at unsw.edu.au
Wed Feb 8 01:39:55 CET 2006


I downloaded and installed Bob's binary of wxPython for 2.4, which  
seems to work nicely but expects PyOpenGL to be installed.  So I  
tried installing it and fell right back into the header file messes  
again.

Issues so far:
1. the current source tarball has a big problem.  There is a script,  
get_gl_extensions.py, at the top level of the cvs code which adds a  
heap of cruft starting '#include <GL/glext.h> on to the end of almost  
all the wrapper .i files.  This include does not work on MacOS but  
even changing it to <OpenGL/glext.h> just results in a load of  
'syntax error's.   Using CVS code gets over this.  It seems the  
offending script was merged to the head in July 2005.  Does any one  
know why?

2. config/ darwin.cfg adds /System/Library/Frameworks/ 
Kernel.framework/Headers to the header search path.
This creates a problem because '#include <stat.h> then includes the  
Kernel framework version of stat.h which lacks necessary  
declarations. This issue has also been reported by others on PyOpenGL  
mail lists.  Does anyone know why the Kernel framework is used?

3. around src/config.h:96 there is code like
#ifdef CGL_PLATFORM
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#include <glut.h>
#else
this leaves certain functions undeclared such as CGLGetCurrentContext.

Altering the code thus removes these problems
#ifdef CGL_PLATFORM
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#include <OpenGL/OpenGL.h>
#include <GLUT/glut.h>
#else

this change has a side benefit of rendering the include_dirs on line  
14 of darwin.cfg unnecessary.  A directive like '#include <OpenGL/ 
gl.h>' automatically searches the standard framework search path (~/ 
Library/Frameworks:/Library/Frameworks:/System/Library/Frameworks)  
for an OpenGL.framework and the loads the header from the Headers  
directory in that framework.

4. at src/gle/src/texgen.c around line 14 there is the following:
#ifdef __APPLE_CC__
/#include <sys/types.h> /* Darwin has a bug that doesn't define  
u_short in */
/#include <sys/malloc.h> /* malloc.h, so we have to get it through  
stdio.h. */
#else
#include <malloc.h>
#endif

this results in malloc and realloc not being declared.  I have no  
idea how this code got concocted.  All the sources I have consulted  
(Apple's documentation, Opengroup standards and even my 1988 copy of  
K&R) say malloc and realloc are provided by <stdlib.h>.  Changing the  
code as below results in all the warnings going away

  #ifdef __APPLE_CC__
#include <stdlib.h>
#else
#include <malloc.h>
#endif

With these changes the cvs code for PyOpenGL builds happily, although  
there are still a lot of warnings.

Thanks
Bill Northcott

PS This build works happily with _POSIX_C_SOURCES defined!


More information about the Pythonmac-SIG mailing list