Trouble getting started


Hello! I am new to using GLFW and I am not sure if my setup is good. In windows 10 x64, I am trying the openGL tutorials, when trying to compile, I get this error:

||=== Build: Debug in tutorial project (compiler: GNU GCC Compiler) ===|
 project.exe obj\Debug\tutorial02.o   ..\LIB\glew32s.lib ..\LIB\libglfw3.a||No such file or directory|
||error: no input files|
||=== Build failed: 2 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|

This is using code::blocks with the mingw32 compiler. I included the headers for both GLFW and GLEW, I set the linker to glew32s.lib and libglfw3.a. Here is the code from the tutorial:

// Include standard headers
#include <stdio.h>
#include <stdlib.h>

// Include GLEW
#include <GL/glew.h>

// Include GLFW
#include <glfw3.h>
GLFWwindow* window;

// Include GLM
#include <glm/glm.hpp>
using namespace glm;

#include <common/shader.hpp>

int main( void )
    // Initialise GLFW
    if( !glfwInit() )
        fprintf( stderr, "Failed to initialize GLFW\n" );
        return -1;

    glfwWindowHint(GLFW_SAMPLES, 4);
    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
    glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
    glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); // To make MacOS happy; should not be needed

    // Open a window and create its OpenGL context
    window = glfwCreateWindow( 1024, 768, "Tutorial 02 - Red triangle", NULL, NULL);
    if( window == NULL ){
        fprintf( stderr, "Failed to open GLFW window. If you have an Intel GPU, they are not 3.3 compatible. Try the 2.1 version of the tutorials.\n" );
        return -1;

    // Initialize GLEW
    glewExperimental = true; // Needed for core profile
    if (glewInit() != GLEW_OK) {
        fprintf(stderr, "Failed to initialize GLEW\n");
        return -1;

    // Ensure we can capture the escape key being pressed below
    glfwSetInputMode(window, GLFW_STICKY_KEYS, GL_TRUE);

    // Dark blue background
    glClearColor(0.0f, 0.0f, 0.4f, 0.0f);

    GLuint VertexArrayID;
    glGenVertexArrays(1, &VertexArrayID);

    // Create and compile our GLSL program from the shaders
    GLuint programID = LoadShaders( "SimpleVertexShader.vertexshader", "SimpleFragmentShader.fragmentshader" );

    static const GLfloat g_vertex_buffer_data[] = { 
        -1.0f, -1.0f, 0.0f,
         1.0f, -1.0f, 0.0f,
         0.0f,  1.0f, 0.0f,

    GLuint vertexbuffer;
    glGenBuffers(1, &vertexbuffer);
    glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer);
    glBufferData(GL_ARRAY_BUFFER, sizeof(g_vertex_buffer_data), g_vertex_buffer_data, GL_STATIC_DRAW);


        // Clear the screen
        glClear( GL_COLOR_BUFFER_BIT );

        // Use our shader

        // 1rst attribute buffer : vertices
        glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer);
            0,                  // attribute 0. No particular reason for 0, but must match the layout in the shader.
            3,                  // size
            GL_FLOAT,           // type
            GL_FALSE,           // normalized?
            0,                  // stride
            (void*)0            // array buffer offset

        // Draw the triangle !
        glDrawArrays(GL_TRIANGLES, 0, 3); // 3 indices starting at 0 -> 1 triangle


        // Swap buffers

    } // Check if the ESC key was pressed or the window was closed
    while( glfwGetKey(window, GLFW_KEY_ESCAPE ) != GLFW_PRESS &&
           glfwWindowShouldClose(window) == 0 );

    // Cleanup VBO
    glDeleteBuffers(1, &vertexbuffer);
    glDeleteVertexArrays(1, &VertexArrayID);

    // Close OpenGL window and terminate GLFW

    return 0;

Any advice would be greatly appreciated, thank you!


Your error from the build output is only showing part of the build, since the source file appears to have been compiled to tutorial02.o - so this part seems fine. Code::Blocks also seems to be mangling some of the GCC output, but it looks like you have not specified the location and / or names of the libraries correctly. Normally you specify the name of the GLFW library as glfw3.

I’m not that familiar with MinGW (Visual Studio Community edition is free and easy to use on Windows), but glew32s.lib is a Visual Studio library so you probably need to use a MinGW built one or just include glew.c in your project.


Interesting, I am using the precompiled files from the GLFW main page, inside there are folders called “lib-mingw” and a bunch called “lib-vc2010” “-2015”. I figured I should use the one called “lib-mingw”, inside the files are libglfw3.a, glfw3.dll and libglfw3dll.a.

Should I have to do anything with those .a files? I used them as is. I am pretty new to using non standard libraries so any help you can give me is much appreciated.


The file @dougbinks is referring to is glew32s.lib, which is not part of GLFW. The GLFW files you mention are the right ones for MinGW, but you may need to compile GLEW yourself.


Thanks for the help, I have so much trouble getting glew to work… I even tried visual studio and I can’t get it to work. this is quite discouraging. I’ve done stuff with openGL 2.0 in the past and now I thought I’d learn opengl 3+… never expected it to be SO complicated to get going.


If GLEW isn’t working for you, perhaps try some of the better (in my opinion) alternatives? I’ve found gl3w ( very straightforward to use for OpenGL 3.3 specifically (no configuration necessary or possible). GLFW uses GLAD (, which looks quite a bit more flexible.

It really shouldn’t be so difficult… but once you’ve got a loader to work once, you should be able to do it in future much more easily.


Since you’re having trouble getting started, I recommend splitting the problem in two to start with. First get GLFW working, then add GLEW (or gl3w or GLAD).

  1. Start with the code from this example which just opens a window.
  2. See the GLFW building applications page for your system.
  3. Build and check everything works - you should get an open window.
  4. For building with GLEW just add the the file glew.c to your project or make file and include glew.h, adding the initialize GLEW code you have in your example, but not making any other code changes.
  5. You should now have a working example which includes an extension loader, so can start to work on trying out your tutorial code.


Thank you very much for your replies, I followed Doug’s advice and to my amazement I was able to produce a simple opengl window! I had to include the opengl32 and gdi32 libraries for it to work.
The second part did not prove successful, perhaps I did not quite understand the next step. Should I use the file from “code from this example”, include the glew.c to the project, add the glew.h header and then compile? Should I still link open32 and gdi32? Any other lib needed?


Hi @alex303

Sounds like you’ve managed to get to step 3 in my list - you’ve built a GLFW app using the instructions on the page about building applications.

To use GLEW you can simply add the glew.c source file to the project you’ve made in the previous step, keeping the libraries you’ve added. Then include the glew.h file and then call glewInit() before you call opengl functions but after the window creation.


Feels like I’m getting somewhere now, it worked up to the point where I add the glewInit(); function after I call "glfwMakeContextCurrent(window); Then compiling takes quite some time for the glew.c file, but I get an error at the line where I put glewInit(), says undefined reference to `_imp__glewInit@0’.

my header is like this:
include GL/glew.h>
include GLFW/glfw3.h>
include GL/gl.h>

I removed the # and < to post those because It doesnt show well in the preview, but they are present in the code. Any help you can give me going through this is very much appreciated