GLUT_DISABLE_ATEXIT_HACK and Dante's Inferno

So I’m getting worked over by the ATEXIT_HACK error below: I am trying to follow a tutorial I like where the only language seems to be glut.h. I am unable to get glut going. I have gotten freeglut no problem: should I switch to that?
I’ve also made a glut_h file with the fix verified in it but no help. Here’s my skeleton program:(below). Do I persevere at debugging this or swtch to what I know works, but will it really works (glut–>freeglut)


#include <windows.h>  // For MS Windows
#define GLUT_DISABLE_ATEXIT_HACK
#include <glut.h>  // GLUT, includes glu.h and gl.h

    int WINDOW_WIDTH = 540;
    int WINDOW_HEIGHT = 540;
    int main(int argc, char** argv)
    {
    //initialize necessary GLUT things
            glutInit(&argc, argv);
            glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
            glutInitWindowPosition(100,100);
            glutInitWindowSize(320,320);
            glutCreateWindow("Lighthouse3D- GLUT Tutorial");

            return 1;
    }


 C:\MinGW\include\GL\glut.h:58:0: warning: ignoring #pragma comment  [-Wunknown-pragmas]
 #  pragma comment (lib, "winmm.lib")      /* link with Windows MultiMedia lib */
 ^
C:\MinGW\include\GL\glut.h:66:0: warning: ignoring #pragma comment  [-Wunknown-pragmas]
 #   pragma comment (lib, "opengl32.lib")  /* link with Microsoft OpenGL lib */
 ^
C:\MinGW\include\GL\glut.h:67:0: warning: ignoring #pragma comment  [-Wunknown-pragmas]
 #   pragma comment (lib, "glu32.lib")     /* link with Microsoft OpenGL Utility lib */
 ^
C:\MinGW\include\GL\glut.h:68:0: warning: ignoring #pragma comment  [-Wunknown-pragmas]
 #   pragma comment (lib, "glut32.lib")    /* link with Win32 GLUT lib */
 ^
C:\MinGW\include\GL\glut.h:76:0: warning: ignoring #pragma warning  [-Wunknown-pragmas]
 #  pragma warning (disable:4244)  /* Disable bogus VC++ 4.2 conversion warnings. */
 ^
C:\MinGW\include\GL\glut.h:77:0: warning: ignoring #pragma warning  [-Wunknown-pragmas]
 #  pragma warning (disable:4305)  /* VC++ 5.0 version of above warning. */
 ^
C:\MinGW\include\GL\glut.h:50:24: error: redeclaration of C++ built-in type 'wchar_t' [-fpermissive]
 typedef unsigned short wchar_t;
                        ^
In file included from <command-line>:0:0:
C:\MinGW\include\GL\glut.h:531:21: warning: 'int glutCreateMenu_ATEXIT_HACK(void (__attribute__((__cdecl__)) *)(int))' defined but not used [-Wunused-function]
 static int APIENTRY glutCreateMenu_ATEXIT_HACK(void (GLUTCALLBACK *func)(int)) { return __glutCreateMenuWithExit(func, exit); }
                     ^

Survey says:

you may have an option, but consider flipping to freeglut.

[QUOTE=Dark Photon;1287626]Survey says:

you may have an option, but consider flipping to freeglut.[/QUOTE]

Just cannot get the macro to work. Seems like by internet results this works for many people. Buried iin the yellow pragma I do have a red error. When I look it up it hsoots me to UK/China.

I am putting the macro before “glut.h”.
I’ve also tried a fixed h file no luck.
Ive read the other options: I am good with freeglut, but I am very stubborn with letting this go in case I need pure glut


C:\bil_inc_lib\include\glut.h:58:0: warning: ignoring #pragma comment  [-Wunknown-pragmas]
 #  pragma comment (lib, "winmm.lib")      /* link with Windows MultiMedia lib */
 ^
C:\bil_inc_lib\include\glut.h:66:0: warning: ignoring #pragma comment  [-Wunknown-pragmas]
 #   pragma comment (lib, "opengl32.lib")  /* link with Microsoft OpenGL lib */
 ^
C:\bil_inc_lib\include\glut.h:67:0: warning: ignoring #pragma comment  [-Wunknown-pragmas]
 #   pragma comment (lib, "glu32.lib")     /* link with Microsoft OpenGL Utility lib */
 ^
C:\bil_inc_lib\include\glut.h:68:0: warning: ignoring #pragma comment  [-Wunknown-pragmas]
 #   pragma comment (lib, "glut32.lib")    /* link with Win32 GLUT lib */
 ^
C:\bil_inc_lib\include\glut.h:76:0: warning: ignoring #pragma warning  [-Wunknown-pragmas]
 #  pragma warning (disable:4244)  /* Disable bogus VC++ 4.2 conversion warnings. */
 ^
C:\bil_inc_lib\include\glut.h:77:0: warning: ignoring #pragma warning  [-Wunknown-pragmas]
 #  pragma warning (disable:4305)  /* VC++ 5.0 version of above warning. */
 ^
C:\bil_inc_lib\include\glut.h:50:24: error: redeclaration of C++ built-in type 'wchar_t' [-fpermissive]
 typedef unsigned short wchar_t;
                        ^
In file included from <command-line>:0:0:
C:\bil_inc_lib\include\glut.h:468:22: warning: 'void glutInit_ATEXIT_HACK(int*, char**)' defined but not used [-Wunused-function]
 static void APIENTRY glutInit_ATEXIT_HACK(int *argcp, char **argv) { __glutInitWithExit(argcp, argv, exit); }
                      ^
C:\bil_inc_lib\include\glut.h:485:21: warning: 'int glutCreateWindow_ATEXIT_HACK(const char*)' defined but not used [-Wunused-function]
 static int APIENTRY glutCreateWindow_ATEXIT_HACK(const char *title) { return __glutCreateWindowWithExit(title, exit); }
                     ^
C:\bil_inc_lib\include\glut.h:531:21: warning: 'int glutCreateMenu_ATEXIT_HACK(void (__attribute__((__cdecl__)) *)(int))' defined but not used [-Wunused-function]
 static int APIENTRY glutCreateMenu_ATEXIT_HACK(void (GLUTCALLBACK *func)(int)) { return __glutCreateMenuWithExit(func, exit); }
                     ^

Maybe a more apropos question would be can I use freeGlut completely for a GLUT site. Will using freeGLUT impose restrictions for a site requiring GLUT? From what I understand freeGLUT umbrellas over GLUT. ??

[QUOTE=technologist;1287634]…I do have a red error. …


C:\bil_inc_lib\include\glut.h:50:24: error: redeclaration of C++ built-in type 'wchar_t' [-fpermissive]
 typedef unsigned short wchar_t;
                        ^
...

[/QUOTE]

A guess: Could be that the glut.h is incompatible with including <windows.h> first. Try getting rid of that, or moving <windows.h> after <glut.h>

Maybe a more apropos question would be can I use freeGlut completely for a GLUT site. Will using freeGLUT impose restrictions for a site requiring GLUT? From what I understand freeGLUT umbrellas over GLUT. ??

FreeGLUT is a free implementation of GLUT. It’s a stand-alone GLUT implementation. So no, it doesn’t umbrella over some other GLUT implementation. You can use it alone. For many folks, it’s the only GLUT implementation they’ve ever used. So you should be able to just use FreeGLUT instead if you want.

[QUOTE=Dark Photon;1287635]A guess: Could be that the glut.h is incompatible with including <windows.h> first. Try getting rid of that, or moving <windows.h> after <glut.h>

FreeGLUT is a free implementation of GLUT. It’s a stand-alone GLUT implementation. So no, it doesn’t umbrella over some other GLUT implementation. You can use it alone. For many folks, it’s the only GLUT implementation they’ve ever used. So you should be able to just use FreeGLUT instead if you want.[/QUOTE]

But will it work with a GLUT site. I’ll give it a shot.

What do you mean by a “site”. Web site?

“GLUT” with “site” didn’t make any sense to me, so I assumed you meant “GLUT app” and chalked it up to a possible English-as-second-language issue.

[QUOTE=Dark Photon;1287640]What do you mean by a “site”. Web site?

“GLUT” with “site” didn’t make any sense to me, so I assumed you meant “GLUT app” and chalked it up to a possible English-as-second-language issue.[/QUOTE]

Sorry! I meant a tutorial site that bases all of its teaching points and examples on GLUT.

Ah! That makes sense to me now :slight_smile:

Ok, got the GLUT all version done without the freeglut. Had to be done, even though will still go with freeglut.
I set compiler settings to library:

-lglu32
-lglut32
-lopengl32

include settings to my includes library:

“C:\bil_inc_lib\include”

Now we have a skeleton Lighthouse initialization code all ready to go(below).

BUT: this doesn’t work, plz help
As discussed want to store all .hs under one folder
#include <GL/glut.h>
here:
#include <…/bin_inc_lib/includes/glut.h>, where includes are my includes


#include <windows.h>  // for MS Windows
#include <GL/glut.h>
#include <iostream>

void renderScene(void) {

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    glBegin(GL_TRIANGLES);
        glVertex3f(-0.5,-0.5,0.0);
        glVertex3f(0.5,0.0,0.0);
        glVertex3f(0.0,0.5,0.0);
    glEnd();

        glutSwapBuffers();
}

int main(int argc, char **argv) {

    // init GLUT and create Window
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
    glutInitWindowPosition(100,100);
    glutInitWindowSize(320,320);
    glutCreateWindow("Lighthouse3D - GLUT ONLY Tutorial");

    // register callbacks
    glutDisplayFunc(renderScene);

    // enter GLUT event processing cycle
    glutMainLoop();

    return 1;
}

For folks to help you, you need to tell them more about the problem (e.g. what doesn’t work, what triggered it, what the error is, and what you’ve done to try and resolve it).

Works fine for me here on Linux, if I surround the windows.h include with #ifdef WIN32 … #endif.

just try to follow one of the hundreds of tutorials out on the web, especially on youtube where you can see each step you’ve got to do

  1. what is your problem ?
    doesnt it compile ?
    do you get linking errors ?
    a “crash” ? (missing dll)

  2. the compiler doesnt care where you want to put all your files, as long as it can find your .h files (of course YOU have to tell it via the “include directories” settings in your IDE)

  3. the same is true for the linker, as long as it can find all the .lib or .a files needed build the .exe (and the .dll files in case you want it to be dynamically linked) (of course YOU have to tell it via the “libraries” settings in your IDE)

This is the first time I’ve tried to statically linked the Gl files in my project. It says it cannot find the files but everytime I try manually tracing the file addresses it leads me back to the file in question:

e.g.

g++ “-LC:\bil_inc_lib\library” -o tut_01_openGl.exe “src\main.o” -lglu32s.lib -llibglfw3dll.a -llibglfw3.a -lglu32.lib
c:/mingw/bin/…/lib/gcc/mingw32/5.3.0/…/…/…/…/mingw32/bin/ld.exe: cannot find -lglu32s.lib
c:/mingw/bin/…/lib/gcc/mingw32/5.3.0/…/…/…/…/mingw32/bin/ld.exe: cannot find -llibglfw3dll.a
c:/mingw/bin/…/lib/gcc/mingw32/5.3.0/…/…/…/…/mingw32/bin/ld.exe: cannot find -llibglfw3.a
c:/mingw/bin/…/lib/gcc/mingw32/5.3.0/…/…/…/…/mingw32/bin/ld.exe: cannot find -lglu32.lib
collect2.exe: error: ld returned 1 exit status

As far as I know I am going c->bil_inc_lib->library

18:37:59 Build Finished (took 174ms)

I have read that the compiler automatically automatically adds-lib and a suffix, e.g. libfglfw3.a ->glfw3

Is this how it goes?

[QUOTE=technologist;1287717]I have read that the compiler automatically automatically adds-lib and a suffix, e.g. libfglfw3.a ->glfw3

Is this how it goes?[/QUOTE]

Lifted, another example:

Change:
gcc -Wall -o test sample.o -L …/lib/cspec -llibcspec.a
to:
gcc -Wall -o test sample.o -L …/lib/cspec -lcspec
(By convention, gcc and other nix compilers automatically add thelib*prefix and the appropriate suffix.)

Sort of. The prefix depends upon the platform (on Unix, libraries always have a “lib” prefix, on Windows they don’t). As for the suffix, it may try multiple suffixes (e.g. .so or .dll for dynamic libraries, then .a or .lib for static libraries). And it’s the linker which performs these steps.