Visual Studio 2012 - error LNK1104: cannot open file 'glew32.lib'

Jebathon picture Jebathon · Jan 1, 2014 · Viewed 78.5k times · Source

I am having issues compiling a basic openGL program on VS 2012. I get a build error upon compiltation giving me:

1>LINK : fatal error LNK1104: cannot open file 'glew32.lib'

I followed the instructions given to me by the documentation for GLEW.

In your OpenGL project open Project -> Properties -> Configuration Properties -> Linker -> Input -> Additional Dependencies -> add glew32.lib.

Also you must include #include in your sources; For that add path to your glew folder: Project -> Properties -> Configuration Properies -> General -> VC++ Directories -> Include Directories and Library Directories;

C/C++ Tab -> General -> Additional Include Directories - Add lib folder there

I have also added the glew32.dll onto my Debug folder within my project folder along with the executable. So far I keep getting this error.

If you need any more further clarification of the steps I have done please don't hesitate to ask

Answer

Andon M. Coleman picture Andon M. Coleman · Jan 1, 2014

In all honesty, there is no real benefit to using the DLL version of glew (short of reduced executable size, but this hardly matters on modern Windows PCs).

It is not like you can simply drop a new version of the DLL into your application and use extensions that you never used before. Likewise, bug fixes are so infrequent/unnecessary with a library that basically just parses the extension spec. files that using the DLL as a means of fixing extension loading bugs in shipped software is also not practical. Statically linking to glew (this means glew32s.lib) makes much more sense in the long run.

The static linking library is also more portable on Windows, it will work with MSVC and MinGW (whereas the DLL library only works with MSVC). Link against glew32s and put that in whatever directory you decided to use for additional library dependencies.


Here is a sample solution configuration for a project I wrote that uses glew. I have established a convention for this particular software where compile-time dependencies are stored under platform/<Subsystem>. Thus, I have glew32s.lib (32-bit) and glew64s.lib (64-bit) in ./Epsilon/platform/OpenGL/glew{32|64}s.lib

  enter image description here