Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm literally an absolute noob in GL. I just wrote my first GLEW piece of code yesterday:

#include <stdio.h>
#include <stdlib.h>
#include <GL/glew.h>
#include <GL/glfw.h>

int main(void)
{
    glfwInit();
    glfwOpenWindowHint(GLFW_FSAA_SAMPLES, 4);
    glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, 3);
    glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, 3);
    glfwOpenWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
    glfwOpenWindow(640, 480, 8, 8, 8, 0, 24, 0, GLFW_WINDOW);

    glewInit();

    glfwSetWindowTitle("OpenGL Rules!");
    glfwEnable( GLFW_STICKY_KEYS );

    do{
    glfwSwapBuffers();
    }while( glfwGetKey( GLFW_KEY_ESC ) != GLFW_PRESS && glfwGetWindowParam( GLFW_OPENED ) );    
}

This compiles just fine with (using mingw on win8 x64):

gcc opengl.c -lglfw -lglew32 -lopengl32

However, in order to run the output, I have to copy the glew32.dll to the same directory from which I'm running the program. Is there a way to get independent from the dll? Like, compiling once and using without having to carry the dll around?

share|improve this question
add comment

1 Answer

up vote 4 down vote accepted

You need to #define GLEW_STATIC before you #include the GLEW headers, then link to glew32s instead of glew32 and you'll statically link to GLEW.

According to http://glew.sourceforge.net/install.html you can also directly use the glew.c and glew.h files in your own project, but I haven't tried that; the GLEW_STATIC method works well enough.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.