# Static compile glfw

**URL:** <https://discourse.glfw.org/t/static-compile-glfw/270>\
**Category:** support\
**Created:** [August 21, 2011, 2:38pm UTC](https://discourse.glfw.org/t/static-compile-glfw/270 "2011-08-21T14:38:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex035/uploads/glfw/original/1X/b8cdefe6b61b8d5aee6c43b2c56e9cf5eabecfe4.svg) [@system](https://discourse.glfw.org/u/system)\
**Post date:** [August 21, 2011, 2:38pm UTC](https://discourse.glfw.org/t/static-compile-glfw/270/1 "2011-08-21T14:38:38Z")

</div>

**[pixelblender3d](https://sourceforge.net/u/pixelblender3d/)** wrote on [Sunday, August 21, 2011](https://sourceforge.net/p/glfw/discussion/247562/thread/ed3da488/#77a3):

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex035/uploads/glfw/original/1X/b8cdefe6b61b8d5aee6c43b2c56e9cf5eabecfe4.svg) [@system](https://discourse.glfw.org/u/system)\
**Post date:** [August 21, 2011, 4:38pm UTC](https://discourse.glfw.org/t/static-compile-glfw/270/2 "2011-08-21T16:38:42Z")

</div>

**[elmindreda](https://sourceforge.net/u/elmindreda/)** wrote on [Sunday, August 21, 2011](https://sourceforge.net/p/glfw/discussion/247562/thread/ed3da488/#9f20):

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