Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GLEW linking errors [duplicate]

Tags:

c++

opengl

glew

Im trying to put together a GLSL example program from a website, just so i can get a feel for shaders.

The shader example program is from http://www.swiftless.com/tutorials/glsl/1_setup.html#DL

1>------ Build started: Project: TheLightingExperiment2, Configuration: Debug Win32 ------

1>shader.obj : error LNK2001: unresolved external symbol __imp____glewLinkProgram

1>shader.obj : error LNK2001: unresolved external symbol __imp____glewAttachShader

1>shader.obj : error LNK2001: unresolved external symbol __imp____glewCreateProgram

1>shader.obj : error LNK2001: unresolved external symbol __imp____glewCompileShader

1>shader.obj : error LNK2001: unresolved external symbol __imp____glewShaderSource

1>shader.obj : error LNK2001: unresolved external symbol __imp____glewCreateShader

1>shader.obj : error LNK2001: unresolved external symbol __imp____glewDeleteProgram

1>shader.obj : error LNK2001: unresolved external symbol __imp____glewDeleteShader

1>shader.obj : error LNK2001: unresolved external symbol __imp____glewDetachShader

1>shader.obj : error LNK2001: unresolved external symbol __imp____glewUseProgram

1>C:\Users\Shawn\Desktop\TheLightingExperiment2\Debug\TheLightingExperiment2.exe : fatal error LNK1120: 10 unresolved externals

========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

The errors appear to be from glew not linking correctly. But i following glew's documentation for linking glew @ http://glew.sourceforge.net/install.html

And it still gives me these errors. I have put glew32.lib in linker->input. I have put the the glew32.lib into the VC lib directory, as well as the glew includes in the VC include directory. From googleing my problem, this seems to be the resolution, but its not working for me.

like image 621
shawn a Avatar asked Dec 11 '22 23:12

shawn a


2 Answers

Save yourself a lot of trouble and just add glew.c to your project. Make sure you #define GLEW_STATIC, and everything will be fine. It is not worth it trying to link to GLEW dynamically.

like image 68
TheBuzzSaw Avatar answered Dec 14 '22 12:12

TheBuzzSaw


I ran into the same linking problem using VS.

It turned out that you should use Win32 lib instead of x64 ones

like image 34
shrekshao Avatar answered Dec 14 '22 12:12

shrekshao