Cannot open file freeglut.lib

So I just got OpenGL super bible 5th edition and I cant get past chapter 1. Every time I compile it says “Cannot open file freeglut.lib”
I have freeglut_static added and all my references to my libraries are right (hopefully?).
Im using MSVS 2010 btw.

I’d guess that it’s not looking for “freeglut_static.lib”, because it says that it’s looking for “freeglut.lib”. See the difference?

Well in the book it doesn’t mention freeglut.lib anywhere, only the freeglut_static one.
Also another error that is occuring is when I compile it “Unable to start the program …/project/triangle/debug/triangle.exe the system cannot find the file specified”.

I added freeglut.lib to check it out, but I got even more errors then before.

Well, since linking fails no executable is produced so it is no surprise that triangle.exe can not be found and started :wink:

Unfortunately on windows there are two very different types of libraries that both use the .lib extension:

  1. static libraries (which is probably what you want)
  2. import libraries for DLLs.

It’s impossible to be sure, since you did not post the errors you are getting now (hint, hint :wink: ), but my guess is the file called freeglut.lib that you have is actually of kind 2) when you want kind 1).
Try renaming your freeglut_static.lib to freeglut.lib and see if that makes a difference.

Those are the errors that I am getting. After I compile I get a message box that says
“Unable to start the program …/project/triangle/debug/triangle.exe the system cannot find the file specified”.

And at the bottom of my IDE, the error list, it says:
error LNK1104 "cannot open file “freeglut.lib”

I have tried renaming the freeglut_static.lib to freeglut.lib, but I still get errors (different ones though and more of them).

No idea why this doesn’t work correctly.

In the instructions for setting up the build for these, did it tell you where to put these libraries? Did it tell you to provide special command line parameters and such?

The instructions weren’t so great. Its also aimed more for MSVS 2008.

I just figured it out so ill post the solution.

  1. If your having troubles with this just download freeglut.lib (
  2. Copy the freeglut.dll into your windows/system32 folder or windows/SysWOW64 for 64 bit users like me
  3. Add a reference to it in your program and ignore that freeglut_static.lib. I just removed it.

This is what works for me.
Thanks for help.