grapedrink wrote on Monday, May 09, 2011:
Hi I’m getting a Segmentation Fault with the example in the GLFW 2.7 Users
Guide in section 2.4 titled a “Minimal GLFW Application”. I’m Mac OSX 10.6
with Xcode 3.2.5 installed.
I compiled GLFW 2.7 with “make cocoa-install” and then copied libglfw.dylib
over to /usr/local/lib
I’m building with:
g++ -Wall -o test test.cpp -I glfw-2.7 -Lglfw-2.7/lib/cocoa -lglfw -L/usr/X11/lib -lGL
I run with: ./test
and the code seg faults and only print out my “print 1” line.
Any ideas on what I’m doing wrong? I’m suspicious of the GL libraries or
something….
#include <GL/glfw.h>
#include <stdlib.h>
#include <iostream>
using std::cout;
int main( void ) {
int running = GL_TRUE;
// Initialize GLFW
if( !glfwInit() )
exit( EXIT_FAILURE );
// Open an OpenGL window
if( !glfwOpenWindow( 300,300, 0,0,0,0,0,0, GLFW_WINDOW ) ) {
glfwTerminate();
exit( EXIT_FAILURE );
}
// Main loop
while( running ) {
[b] cout<<"print 1\n"; [/b]
// OpenGL rendering goes here...
glClear( GL_COLOR_BUFFER_BIT );
cout<<"print 2\n";
// Swap front and back rendering buffers
glfwSwapBuffers();
// Check if ESC key was pressed or window was closed
running = !glfwGetKey( GLFW_KEY_ESC ) && glfwGetWindowParam( GLFW_OPENED );
}
// Close window and terminate GLFW
glfwTerminate();
// Exit program
exit( EXIT_SUCCESS );
}