Help: request for assistance with PyOpenGL distribution using dis tutils on NT

Background: While stuck on my real work, I'm trying to get a PyOpenGL distribution (1.5.6alpha1 from CVS) working using distutils. Rene Liebscher kindly created an installation script that seems to work for him on Win32 for the 1.5.5 PyOpenGL, and for Jason Petrone (on Linux) using the 1.5.6 source from CVS. I'm working on NT 4.0 sp3, using VC++ 6.0sp3, (I get similar effects on Cygnus, but since I'm not sure the package builds under that compiler I'm not focussing on it yet). When trying to build, I get a long set of errors (see below), the elimination of which is well beyond my meagre VC++ or distutils skills to fix. According to MSDN, the problems I'm getting are normally caused by having a C++ file compiled as a C file. To get around it, you apparently put an ifdef at the top and bottom of the file, but the file concerned (GL.h) has this check, and still reports the errors. I'm assuming there's some flag that needs to be set somewhere, but I don't know what it is. Note: everything builds fine using the old setup script for the latest CVS version on this machine (the one for which I'm trying to get a distutils script).
D:\bin\lang\studio\VC98\BIN\cl.exe /c /nologo /Ox /MD /W3 /GX -Isrc -ID:\bin\lang\Python\Include /Tcsrc/_glumodule.c /Fobuild\temp.win32\Release\src/_glumodule.obj
Doesn't work. The GUI under the old BUILD.py uses:
/nologo /MD /W3 /GX /O2 /Ob2 /I "D:\bin\lang\Python\include" /D "WIN32" /D "_WINDOWS" /D "NDEBUG" /Fp"tmp./_glu.pch" /YX /Fo"tmp./" /Fd"tmp./" /FD /c
and works fine. GL.h has the following code near the top (and close at the bottom):
#ifdef __cplusplus extern "C" { #endif
Which, according to MSDN, should avoid the errors, but doesn't seem to. Here's the output from running setup.py build...
S:\PyOpenGL>setup build running build running build_py warning: build_py: package init file 'OpenGL__init__.py' not found (or not a re gular file) warning: build_py: package init file 'OpenGL\Demo__init__.py' not found (or not a regular file) warning: build_py: package init file 'OpenGL\Demo\da__init__.py' not found (or not a regular file) warning: build_py: package init file 'OpenGL\Demo\dek__init__.py' not found (or not a regular file) warning: build_py: package init file 'OpenGL\Demo\dek\OglSurface__init__.py' no t found (or not a regular file) warning: build_py: package init file 'OpenGL\Demo\srenner__init__.py' not found (or not a regular file) warning: build_py: package init file 'OpenGL\Demo\srenner\Images__init__.py' no t found (or not a regular file) warning: build_py: package init file 'OpenGL\Demo\tom__init__.py' not found (or not a regular file) warning: build_py: package init file 'OpenGL\GL__init__.py' not found (or not a regular file) warning: build_py: package init file 'OpenGL\GLU__init__.py' not found (or not a regular file) warning: build_py: package init file 'OpenGL\GLUT__init__.py' not found (or not a regular file) warning: build_py: package init file 'OpenGL\Tk__init__.py' not found (or not a regular file) warning: build_py: package init file 'OpenGL\shared__init__.py' not found (or n ot a regular file) running build_ext skipping '_opengl' extension (up-to-date) skipping 'openglutil' extension (up-to-date) building '_glu' extension D:\bin\lang\studio\VC98\BIN\cl.exe /c /nologo /Ox /MD /W3 /GX -Isrc -ID:\bin\lan g\Python\Include /Tcsrc/_glumodule.c /Fobuild\temp.win32\Release\src/_glumodule. obj _glumodule.c src\GL/gl.h(1135) : error C2054: expected '(' to follow 'WINGDIAPI' src\GL/gl.h(1135) : error C2085: 'APIENTRY' : not in formal parameter list src\GL/gl.h(1135) : error C2146: syntax error : missing ',' before identifier 'g lAccum' src\GL/gl.h(1135) : error C2143: syntax error : missing ';' before '(' src\GL/gl.h(1135) : error C2059: syntax error : ')' src\GL/gl.h(1136) : error C2054: expected '(' to follow 'WINGDIAPI' src\GL/gl.h(1136) : error C2085: 'APIENTRY' : not in formal parameter list src\GL/gl.h(1136) : error C2146: syntax error : missing ',' before identifier 'g lAlphaFunc' src\GL/gl.h(1136) : error C2143: syntax error : missing ';' before '(' src\GL/gl.h(1136) : error C2059: syntax error : ')' src\GL/gl.h(1137) : error C2054: expected '(' to follow 'WINGDIAPI'
... (100 errors, then stops due to having so many)
Does anyone have any suggestions on how to fix this (keeping in mind that I'm not a C/C++ programmer, so the instructions should be pretty basic)? Thoughts appreciated, Mike __________________________________ Mike C. Fletcher Designer, VR Plumber http://members.home.com/mcfletch

D:\bin\lang\studio\VC98\BIN\cl.exe /c /nologo /Ox /MD /W3 /GX -Isrc -ID:\bin\lang\Python\Include /Tcsrc/_glumodule.c /Fobuild\temp.win32\Release\src/_glumodule.obj
Doesn't work. The GUI under the old BUILD.py uses:
/nologo /MD /W3 /GX /O2 /Ob2 /I "D:\bin\lang\Python\include" /D "WIN32" /D "_WINDOWS" /D "NDEBUG" /Fp"tmp./_glu.pch" /YX /Fo"tmp./" /Fd"tmp./" /FD /c
and works fine.
This is not related to C/C++ problems. The problem is that WIN32 and _WINDOWS is not defined in the first run. Insert the define_macros parameter: Extension("_glu", ["src/_glumodule.c"], libraries=glu_libs, library_dirs=glu_lib_dirs, define_macros=[("WIN32", None), ("_WINDOWS", None)], ), in your setup-script and it should work. (This may also be necessary for other extensions).
Thomas

Thomas Heller wrote:
D:\bin\lang\studio\VC98\BIN\cl.exe /c /nologo /Ox /MD /W3 /GX -Isrc -ID:\bin\lang\Python\Include /Tcsrc/_glumodule.c /Fobuild\temp.win32\Release\src/_glumodule.obj
Doesn't work. The GUI under the old BUILD.py uses:
/nologo /MD /W3 /GX /O2 /Ob2 /I "D:\bin\lang\Python\include" /D "WIN32" /D "_WINDOWS" /D "NDEBUG" /Fp"tmp./_glu.pch" /YX /Fo"tmp./" /Fd"tmp./" /FD /c
and works fine.
This is not related to C/C++ problems. The problem is that WIN32 and _WINDOWS is not defined in the first run. Insert the define_macros parameter: Extension("_glu", ["src/_glumodule.c"], libraries=glu_libs, library_dirs=glu_lib_dirs, define_macros=[("WIN32", None), ("_WINDOWS", None)], ), in your setup-script and it should work. (This may also be necessary for other extensions).
'define_macros' only works with the latest version of distutils.
May be you should use the same include order as in the other c-files. (This file fails to compile.) * _glumodule.c ******************* ... #ifdef WIN32 #include <windows.h> #define MCALLBACK (void (__stdcall *)(void)) #define GLUCALLBACK WINAPI #else #define MCALLBACK #define GLUCALLBACK #endif
#include <GL/gl.h> #include <GL/glu.h> #include "Python.h" ... **********************************
(This one compiles without problems.) * _openglmodule.c **************** ... #include "Python.h" #ifdef MS_WIN32 #include <windows.h> #endif #include <GL/gl.h> #include <math.h> ... **********************************
If you include "Python.h" first and use then MS_WIN32 instead of WIN32, you don't need to define WIN32 and don't get problems with older versions of distutils, which doesn't handle 'define_macros'.
(There are some other occurences of WIN32 in your file, either you replace them or you define WIN32 in your c-file if MS_WIN32 is defined.)
kind regards
Rene Liebscher
participants (3)
-
Mike Fletcher
-
Rene Liebscher
-
Thomas Heller