I built glfw, and the programs in test run just fine, however, when I try to write my own program it segfaults at the line while(!glfwWindowShouldClose(window)) and when I remove this it segfaults on glfwPollEvents(). I am compiling it with cc window.c -lglfw3 -lGLEW -lGL -lX11 -lGLU -lXxf86vm -lXrandr -lpthread -lXi -lm -lXinerama -lXcursor. Why do these functions segfault, and why don't the initialization functions. Full program included bellow.
#include <GL/glew.h> #include <GLFW/glfw3.h> int main(int argc, char** argv){ glfwInit(); glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); glfwWindowHint(GLFW_RESIZABLE, GL_FALSE); GLFWwindow* window = glfwCreateWindow(800, 600, "gl", NULL, NULL); glfwMakeContextCurrent(window); //glewExperimental = GL_TRUE; glewInit(); glViewport(0, 0, 800, 600); while(!glfwWindowShouldClose(window)){ glfwPollEvents(); glClearColor(0.2f, 0.3f, 0.3f, 1.0f); glClear(GL_COLOR_BUFFER_BIT); glfwSwapBuffers(window); } glfwTerminate(); return 0; }
windowto make sure it's non-NULL. It's possible you're failing to create a window because of your specific combination of version and profile hints.