minimal init program not working

In the following code my goal is to initialize without an error. I am using the simplest, most minimal code possible (as far as I know):
Code :

1
2
3
4
5
6
7
8
9

#include<GL/glut.h>
 
int main(int argc, char *argv[])
{
	glutInit(&argc, argv);
	return 1;
}


glut32.dll in same folder as .exe

compiles fine, error:
3d_initialize.exe stopped working
Your program returns value 1. For shell 0 means success, anything else (like 1) means failure.

Not sure whether that is your problem.
return 0

didn't change result.

Addendum:

This GDB was configured as "mingw32".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
[New Thread 3900.0x1ef4]
gdb: unknown target exception 0xc0000139 at 0x7701d4c2

I'm not very adept at debugging, but there it is.
Last edited on
what did you type in for the command line parameters?
if u mean argc and *argv I let them carry from the int main command line parameters. I also tried making main(int argc, char*argv[]) "normal" by removing the arguments from main() and by substituting dummy arguments in glutInit etc (or something like that):

1
2
3
4
5
6
7
int main()
{
  int argc = 1;
  char *argv[1] = {(char*)"Something"};
  glutInit(&argc, argv);
...
}


still crashes at runtime
Amazingly, the addition of the following parameter completely resolved the problem and resulted in a running program:

 
#define GLUT_DISABLE_ATEXIT_HACK 


to before the .h

1
2
3
4
5
6
7
8
9
10
11
#include <iostream>
#define GLUT_DISABLE_ATEXIT_HACK
#include <GL/glut.h>

int main(int argc, char *argv[])
{
	std::cout<<"Hello GL World"<<std::endl;
	glutInit(&argc, argv);
	return 0;
}


MUST put a copy of glut32.dll in the same folder as project .exe or the runtime error will continue but for a different reason.

Here is the dummy argument version as above. But you have to add the #define GLUT_DISABLE_ATEXIT_HACK BEFORE #include <GL/glut.h>:

1
2
3
4
5
6
7
8
9
10
11
#include <iostream>
#define GLUT_DISABLE_ATEXIT_HACK
<GL/glut.h>

int main()
{
  int argc = 1;
  char *argv[1] = {(char*)"Something"};
  glutInit(&argc, argv);
...
}
Last edited on
Topic archived. No new replies allowed.