Static compile glfw

pixelblender3d wrote on Sunday, August 21, 2011:

Hi,

inside my project directory i got “external/glfw” which contains glfw 2.7.1
source. i’ve compiled it by running “make x11-install” which put:
/usr/local/include/GL/glfw.h
/usr/local/lib/libglfw.a
/usr/local/lib/pkgconfig/libglfw.pc

i also got this simple code in test.c:

#include <stdio.h>
#include <stdlib.h>
#include "external/glfw/include/GL/glfw.h"
int main( int argc, char const* argv[] )
{
    if( !glfwInit() ){
        fprintf( stderr, "Init Failed\n" );
    }
    glfwOpenWindowHint( GLFW_FSAA_SAMPLES, 4 );
    glfwOpenWindowHint( GLFW_OPENGL_VERSION_MAJOR, 3 );
    glfwOpenWindowHint( GLFW_OPENGL_VERSION_MINOR, 1 );
    glfwOpenWindowHint( GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE );
    // Open a window and create its OpenGL context
    if( !glfwOpenWindow( 1024, 768, 0,0,0,0, 32,0, GLFW_WINDOW )){
        fprintf( stderr, "failed at glfwOpenWindow\n" );
        glfwTerminate();
        return -1;
    }
    
    return 0;
}

i’m trying to compile glfw as static link and compiled the code using gcc with
flags:

/usr/bin/gcc `pkg-config --cflags libglfw` -o test test.c `pkg-config --libs libglfw` -lXrandr  -lX11 -lGLU -lGL -pthread -lm

and it doesn’t give me any error. but when i try to execute the binary it
shows that i’ve failed to call glfwOpenWindow. could any one help me please?

thank you for your time guys!

cheers!

P

elmindreda wrote on Sunday, August 21, 2011:

Do you really mean that you failed to call glfwOpenWindow or do you mean that
the call to glfwOpenWindow failed?