PDA

View Full Version : GLUT_DISABLE_ATEXIT_HACK and Dante's Inferno



technologist
06-21-2017, 03:36 PM
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); }
^

Dark Photon
06-21-2017, 05:44 PM
I am unable to get glut going. I have gotten freeglut no problem: should I switch to that?


Survey says:
* macro #define GLUT_DISABLE_ATEXIT_HACK (https://www.opengl.org/discussion_boards/showthread.php/170489-macro-define-GLUT_DISABLE_ATEXIT_HACK)
* Using freeglut or GLUT with MinGW (http://www.transmissionzero.co.uk/computing/using-glut-with-mingw/)
* MinGW (https://www.khronos.org/opengl/wiki/MinGW) (OpenGL Wiki)

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

technologist
06-22-2017, 12:39 PM
Survey says:
* macro #define GLUT_DISABLE_ATEXIT_HACK (https://www.opengl.org/discussion_boards/showthread.php/170489-macro-define-GLUT_DISABLE_ATEXIT_HACK)
* Using freeglut or GLUT with MinGW (http://www.transmissionzero.co.uk/computing/using-glut-with-mingw/)
* MinGW (https://www.khronos.org/opengl/wiki/MinGW) (OpenGL Wiki)

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

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

Dark Photon
06-22-2017, 06:25 PM
...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;
^
...


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.

technologist
06-22-2017, 09:00 PM
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.

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

Dark Photon
06-23-2017, 06:04 AM
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.

technologist
06-23-2017, 09:17 AM
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.

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

Dark Photon
06-23-2017, 05:48 PM
Ah! That makes sense to me now :-)

technologist
06-24-2017, 08:31 PM
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;
}

Dark Photon
06-25-2017, 01:30 PM
BUT: this doesn't work, plz help

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.

john_connor
06-25-2017, 01:52 PM
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
https://www.youtube.com/watch?v=8p76pJsUP44

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

1. 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)
2. 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)

technologist
06-30-2017, 04:39 PM
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)

technologist
06-30-2017, 05:23 PM
I have read that the compiler automatically automatically adds-lib and a suffix, e.g. libfglfw3.a ->glfw3

Is this how it goes?

technologist
06-30-2017, 08:16 PM
I have read that the compiler automatically automatically adds-lib and a suffix, e.g. libfglfw3.a ->glfw3

Is this how it goes?

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 the*lib*prefix and the appropriate suffix.)

GClements
07-01-2017, 04:57 AM
I have read that the compiler automatically automatically adds-lib and a suffix, e.g. libfglfw3.a ->glfw3
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.