R
Rene
Hello to all!
For a long time I have been "fighting" a problem compiling an OpenGL
program which uses GLUT. First I have put a question in a Watcom group
(I want to use this compiler) to which I got no reply, in an OpenGL
group somebody recommended me to use Visual C++ which I did. That worked
OK but I do would like to use Watcom.
In the meantime I found solutions to several of the errors I got but one
is left which I cannot find a solution to, my knowledge of C++-compilers
is just to limited. Any help would be very highly appreciated (and sorry
about the long message, I think it is better when one asks for help to
provide the people one is asking help of with all the information I
think is needed).
The problem is when compiling the following program with WPP386, the C++
version of Watcom. WCC386, the C version compiles OK.
My listing (from
http://www.trajectorylabs.com/getting_started_with_opengl_glut.html):
//---------------------------------------------------------------------
// Getting Started with OpenGL GLUT
// A Very Simple OpenGL Example
//
// Draws a simple window with a rectangle in it
//---------------------------------------------------------------------
/* #include <iostream.h> */
#include <stdlib.h>
#include <windows.h>
#include <Gl\gl.h>
#define GLUT_DISABLE_ATEXIT_HACK
#include <Gl\glut.h>
void init(void);
void display(void);
int main (int argc, char **argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
glutInitWindowSize(250, 250);
glutInitWindowPosition(100, 100);
glutCreateWindow("My First OpenGL Application");
init();
glutDisplayFunc(display);
glutMainLoop();
return 0;
}
void init(void)
{
glClearColor(0.0, 0.0, 0.0, 0.0);
glColor3f(0.0, 0.0, 1.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-10.0, 10.0, -10.0, 10.0, -10.0, 10.0);
}
void display(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glRectf(-5.0, 5.0, 5.0, -5.0);
glutSwapBuffers();
}
//---------------------------------------------------------------------
The line #define GLUT_DISABLE_ATEXIT_HACK I got from an explanation on
http://www.di.unipi.it/~nids/docs/watcom_glut_sdl.shtml.
Compiling it as a C++ program gives the following output from the compiler:
C:\WATCOM\Projects>wpp386 -5s pelles.cpp
Open Watcom C++32 Optimizing Compiler Version 1.6
Portions Copyright (c) 1989-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.
See http://www.openwatcom.org/ for details.
C:\WATCOM\H\NT\Gl\glut.h(146): Error! E867: col(38) conflict with a
previous using-decl 'exit'
C:\WATCOM\H\NT\Gl\glut.h(146): Note! N393: col(38) included from
pelles.cpp(13)
C:\WATCOM\H\stdlib.h(48): Note! N392: col(10) definition: 'void watcall
exit( int )'
pelles.cpp: 48 lines, included 46799, no warnings, 1 error
The problem is in glut.h which in its entirety can be found in the
following zip file http://www.xmission.com/~nate/glut/glut-3.7.6-bin.zip
but I will also paste the part of it in which according to the compiler
the problem occurs; there is an explanation about the "exit" thing in
this file, unfortunately my knowledge is too limited to be able to
deduct from it what I should do prevent the error from occuring.
This problem has been giving me quite a lot of headaches already (I am
not exagerating when saying that I spent at least 15 hours surfing the
web and googlegroups to find a solution, but I haven't found one... I am
already very happy that I can finally enjoy my recently bought OpenGL
book when using VC++ but as I want to get into Linux as well and
OpenWatcom is being made cross-platform I would prefer to use that, I
also like the IDE as it is quite simple (like me ;-)).
This is the part of glut.h in which the problem occurs (+ in the
beginning the explanation I mentioned), the line the compiler mentions
is put between "!'s":
/* Win32 has an annoying issue where there are multiple C run-time
libraries (CRTs). If the executable is linked with a different CRT
from the GLUT DLL, the GLUT DLL will not share the same CRT static
data seen by the executable. In particular, atexit callbacks registered
in the executable will not be called if GLUT calls its (different)
exit routine). GLUT is typically built with the
"/MD" option (the CRT with multithreading DLL support), but the Visual
C++ linker default is "/ML" (the single threaded CRT).
One workaround to this issue is requiring users to always link with
the same CRT as GLUT is compiled with. That requires users supply a
non-standard option. GLUT 3.7 has its own built-in workaround where
the executable's "exit" function pointer is covertly passed to GLUT.
GLUT then calls the executable's exit function pointer to ensure that
any "atexit" calls registered by the application are called if GLUT
needs to exit.
Note that the __glut*WithExit routines should NEVER be called directly.
To avoid the atexit workaround, #define GLUT_DISABLE_ATEXIT_HACK. */
/* XXX This is from Win32's <process.h> */
# if !defined(_MSC_VER) && !defined(__cdecl)
/* Define __cdecl for non-Microsoft compilers. */
# define __cdecl
# define GLUT_DEFINED___CDECL
# endif
# ifndef _CRTIMP
# ifdef _NTSDK
/* Definition compatible with NT SDK */
# define _CRTIMP
# else
/* Current definition */
# ifdef _DLL
# define _CRTIMP __declspec(dllimport)
# else
# define _CRTIMP
# endif
# endif
# define GLUT_DEFINED__CRTIMP
# endif
/* GLUT API entry point declarations for Win32. */
# ifdef GLUT_BUILDING_LIB
# define GLUTAPI __declspec(dllexport)
# else
# ifdef _DLL
# define GLUTAPI __declspec(dllimport)
# else
# define GLUTAPI extern
# endif
# endif
/* GLUT callback calling convention for Win32. */
# define GLUTCALLBACK __cdecl
#endif /* _WIN32 */
#include <GL/gl.h>
#include <GL/glu.h>
#ifdef __cplusplus
extern "C" {
#endif
#if defined(_WIN32)
# ifndef GLUT_BUILDING_LIB
!!!!!!!!! extern _CRTIMP void __cdecl exit(int); !!!!!!!!!!!
# endif
#else
/* non-Win32 case. */
/* Define APIENTRY and CALLBACK to nothing if we aren't on Win32. */
# define APIENTRY
# define GLUT_APIENTRY_DEFINED
# define CALLBACK
/* Define GLUTAPI and GLUTCALLBACK as below if we aren't on Win32. */
# define GLUTAPI extern
# define GLUTCALLBACK
/* Prototype exit for the non-Win32 case (see above). */
extern void exit(int);
#endif
Like I said, any help will be highly appreciated!
Yours sincerely,
Rene
P.S. Because of my job I do not have the opportunity to sit at my
computer very often and I can never predict when that will be, so if my
reply takes a while that is not because I am not interested.
P.P.S. Please forgive me language errors, English is not my mother tongue.
For a long time I have been "fighting" a problem compiling an OpenGL
program which uses GLUT. First I have put a question in a Watcom group
(I want to use this compiler) to which I got no reply, in an OpenGL
group somebody recommended me to use Visual C++ which I did. That worked
OK but I do would like to use Watcom.
In the meantime I found solutions to several of the errors I got but one
is left which I cannot find a solution to, my knowledge of C++-compilers
is just to limited. Any help would be very highly appreciated (and sorry
about the long message, I think it is better when one asks for help to
provide the people one is asking help of with all the information I
think is needed).
The problem is when compiling the following program with WPP386, the C++
version of Watcom. WCC386, the C version compiles OK.
My listing (from
http://www.trajectorylabs.com/getting_started_with_opengl_glut.html):
//---------------------------------------------------------------------
// Getting Started with OpenGL GLUT
// A Very Simple OpenGL Example
//
// Draws a simple window with a rectangle in it
//---------------------------------------------------------------------
/* #include <iostream.h> */
#include <stdlib.h>
#include <windows.h>
#include <Gl\gl.h>
#define GLUT_DISABLE_ATEXIT_HACK
#include <Gl\glut.h>
void init(void);
void display(void);
int main (int argc, char **argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
glutInitWindowSize(250, 250);
glutInitWindowPosition(100, 100);
glutCreateWindow("My First OpenGL Application");
init();
glutDisplayFunc(display);
glutMainLoop();
return 0;
}
void init(void)
{
glClearColor(0.0, 0.0, 0.0, 0.0);
glColor3f(0.0, 0.0, 1.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-10.0, 10.0, -10.0, 10.0, -10.0, 10.0);
}
void display(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glRectf(-5.0, 5.0, 5.0, -5.0);
glutSwapBuffers();
}
//---------------------------------------------------------------------
The line #define GLUT_DISABLE_ATEXIT_HACK I got from an explanation on
http://www.di.unipi.it/~nids/docs/watcom_glut_sdl.shtml.
Compiling it as a C++ program gives the following output from the compiler:
C:\WATCOM\Projects>wpp386 -5s pelles.cpp
Open Watcom C++32 Optimizing Compiler Version 1.6
Portions Copyright (c) 1989-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.
See http://www.openwatcom.org/ for details.
C:\WATCOM\H\NT\Gl\glut.h(146): Error! E867: col(38) conflict with a
previous using-decl 'exit'
C:\WATCOM\H\NT\Gl\glut.h(146): Note! N393: col(38) included from
pelles.cpp(13)
C:\WATCOM\H\stdlib.h(48): Note! N392: col(10) definition: 'void watcall
exit( int )'
pelles.cpp: 48 lines, included 46799, no warnings, 1 error
The problem is in glut.h which in its entirety can be found in the
following zip file http://www.xmission.com/~nate/glut/glut-3.7.6-bin.zip
but I will also paste the part of it in which according to the compiler
the problem occurs; there is an explanation about the "exit" thing in
this file, unfortunately my knowledge is too limited to be able to
deduct from it what I should do prevent the error from occuring.
This problem has been giving me quite a lot of headaches already (I am
not exagerating when saying that I spent at least 15 hours surfing the
web and googlegroups to find a solution, but I haven't found one... I am
already very happy that I can finally enjoy my recently bought OpenGL
book when using VC++ but as I want to get into Linux as well and
OpenWatcom is being made cross-platform I would prefer to use that, I
also like the IDE as it is quite simple (like me ;-)).
This is the part of glut.h in which the problem occurs (+ in the
beginning the explanation I mentioned), the line the compiler mentions
is put between "!'s":
/* Win32 has an annoying issue where there are multiple C run-time
libraries (CRTs). If the executable is linked with a different CRT
from the GLUT DLL, the GLUT DLL will not share the same CRT static
data seen by the executable. In particular, atexit callbacks registered
in the executable will not be called if GLUT calls its (different)
exit routine). GLUT is typically built with the
"/MD" option (the CRT with multithreading DLL support), but the Visual
C++ linker default is "/ML" (the single threaded CRT).
One workaround to this issue is requiring users to always link with
the same CRT as GLUT is compiled with. That requires users supply a
non-standard option. GLUT 3.7 has its own built-in workaround where
the executable's "exit" function pointer is covertly passed to GLUT.
GLUT then calls the executable's exit function pointer to ensure that
any "atexit" calls registered by the application are called if GLUT
needs to exit.
Note that the __glut*WithExit routines should NEVER be called directly.
To avoid the atexit workaround, #define GLUT_DISABLE_ATEXIT_HACK. */
/* XXX This is from Win32's <process.h> */
# if !defined(_MSC_VER) && !defined(__cdecl)
/* Define __cdecl for non-Microsoft compilers. */
# define __cdecl
# define GLUT_DEFINED___CDECL
# endif
# ifndef _CRTIMP
# ifdef _NTSDK
/* Definition compatible with NT SDK */
# define _CRTIMP
# else
/* Current definition */
# ifdef _DLL
# define _CRTIMP __declspec(dllimport)
# else
# define _CRTIMP
# endif
# endif
# define GLUT_DEFINED__CRTIMP
# endif
/* GLUT API entry point declarations for Win32. */
# ifdef GLUT_BUILDING_LIB
# define GLUTAPI __declspec(dllexport)
# else
# ifdef _DLL
# define GLUTAPI __declspec(dllimport)
# else
# define GLUTAPI extern
# endif
# endif
/* GLUT callback calling convention for Win32. */
# define GLUTCALLBACK __cdecl
#endif /* _WIN32 */
#include <GL/gl.h>
#include <GL/glu.h>
#ifdef __cplusplus
extern "C" {
#endif
#if defined(_WIN32)
# ifndef GLUT_BUILDING_LIB
!!!!!!!!! extern _CRTIMP void __cdecl exit(int); !!!!!!!!!!!
# endif
#else
/* non-Win32 case. */
/* Define APIENTRY and CALLBACK to nothing if we aren't on Win32. */
# define APIENTRY
# define GLUT_APIENTRY_DEFINED
# define CALLBACK
/* Define GLUTAPI and GLUTCALLBACK as below if we aren't on Win32. */
# define GLUTAPI extern
# define GLUTCALLBACK
/* Prototype exit for the non-Win32 case (see above). */
extern void exit(int);
#endif
Like I said, any help will be highly appreciated!
Yours sincerely,
Rene
P.S. Because of my job I do not have the opportunity to sit at my
computer very often and I can never predict when that will be, so if my
reply takes a while that is not because I am not interested.
P.P.S. Please forgive me language errors, English is not my mother tongue.