[Linux C programming] segmentation fault

Greetings !!

I already dig the internet but failed to find a solution concerning this simple program expected to initialize the glut context…

#include <stdio.h>
#include <stdlib.h>

// Librairie opengl

#include <GL/gl.h>
#include <GL/glut.h>

int windowID;       


int main(int argc,char* argv[],char *envp[]) 
{
  glutInit(&argc,argv); 
  glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH);
  glutInitWindowSize(1024,768);                                                                                                                
  windowID = glutCreateWindow("Not utf8 -- première fenêtre en opengl !!");
  glutFullScreen();

  exit(0);
 }

When debugging, I can see the window opened (that how I can say that the window title does not handle the utf8).
When executing, nothing happened and I got a segmentation fault happening at line 33 (that points to the glutInit() call).

When debugging the SIGSEGV (segmentation fault) signal is sent when program is exiting… all the main functions seem to be executed without any problem.

I know that argc is modified as glutInit extracts any command line options intended for the GLUT library.

I have nothing to pass, for now, to the application, so argc must be 1 and argv to NULL.

What is wrong ? Did I forgot something ?

Did I forgot something ?
Yup, two things. Namely, glutMainLoop and glutDisplayFunc.

#include <stdio.h>
#include <stdlib.h>

// Librairie opengl

#include <GL/gl.h>
#include <GL/glut.h>

int windowID;

void disp() {                     /// added
    glClear(GL_COLOR_BUFFER_BIT); /// added
    glutSwapBuffers();            /// added
}                                 /// added

int main(int argc,char* argv[],char *envp[]) {
    glutInit(&argc,argv);
    glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH);
    glutInitWindowSize(1024,768);
    windowID = glutCreateWindow("Not utf8 -- première fenêtre en opengl !!");
    glutFullScreen();
    glutDisplayFunc(disp);        /// added
    glutMainLoop();               /// added
    exit(0);
}

https://www.opengl.org/documentation/specs/glut/spec3/node16.html - glutCreateWindow is specified as taking an ASCII string. “première fenêtre” certainly doesn’t contain ASCII characters, so I suggest that you correct what is obviously wrong first.

Big thanx !! I’ll try it once at home ^^