GLUT+GLEW=OK, GLFW+GL3W=OK, but GLFW+GLEW=crash in ubuntu

The code in red book for OpenGL 4.3 is GLUT(freeglut actually)+GLEW, which runs ok.

The code in red book for OpenGL 4.5 is GLFW+GL3W, which runs ok too.

Then I am thinking of GLFW+GLEW, but it crashes on ubuntu. The source code is the Sierpinski Gasket from a computer graphics textbook (it’s highly likely familiar to you already). The zip package of the sources is in the attachment. I build it in NetBeans 8.2 on ubuntu 16.04 in which OpenGL 4.5 is installed. The linking option is -lglfw -lGLEW -lGL -ldl. The original GLUT statements (which works with GLEW) are commented out and GLFW codes are added in. The crash happens at line 35 of the main source example1.cpp:

glGenVertexArrays( 1, &vao );

with the segment fault:

I don’t know where I made a mistake or missed something after checking many times, so I submit the problem here in hope that someone could help. If you need any information towards troubleshooting, please let me know. Thank you!

PS: GLFW+GLEW works on Windows 10 + Visual Studio 2015


Then I am thinking of GLFW+GLEW, but it crashes on ubuntu. [/QUOTE]

I tried it and your code works just fine in Ubuntu 18.04 with Glfw and Glew. The main difference that I see from Gl3w and Glew is that Gl3w will only load the core profile functions while Glew loads everything.

@Jesse: thank you very much for trying my code. The ubuntu I am using is my institute’s cluster which is 16.04. I’m afraid the IT will not upgrade to 18.04 until two years later.
PS: you are the first to let me know that ubuntu 18.04 was released :slight_smile:

Just to give you another data point, I tried it here on another Linux box (OpenSuSE Leap 15.0), and it worked great here as well.

I also ran it under valgrind (memcheck) and the output was completely clean – no flagged problems.