Help! GLEW Compiles but Doesn't Link!

| Comments

When you compile the glew_static project from glew on Visual Studio and link it with your program, you may get something like this:

1
2
3
4
5
app_init.obj : error LNK2001: unresolved external symbol __imp__glewInit
worldscene.obj : error LNK2001: unresolved external symbol __imp____glewBufferSubData
worldscene.obj : error LNK2001: unresolved external symbol __imp____glewBufferData
worldscene.obj : error LNK2001: unresolved external symbol __imp____glewBindBuffer
worldscene.obj : error LNK2001: unresolved external symbol __imp____glewGenBuffers

It’s easy to fix. Just add GLEW_STATIC to the preprocessor definitions and you’re done. This is because without it the header specifies dllimport instead of just extern, which is needed for static linkage.

Comments