Why is Visual Studio Trying to Link 'freeglutd.lib'?

someguy picture someguy · Mar 17, 2015 · Viewed 17.2k times · Source

I'm trying to compile an OpenGL program using Visual Studio 2013, but I get the following error:

Error 1 error LNK1104: cannot open file 'freeglutd.lib' ...

For reference, I have FreeGLUT installed and have configured VS to search the correct directories for the include files and library files. Indeed, VS recognises the GLUT include files just fine. I've also added opengl32.lib and freeglut.lib to the Additional Dependencies.

Why is VS looking for 'freeglutd.lib'? It's definitely not listed in the Additional Dependencies. I can solve the compilation error by renaming 'libglut.lib' to 'libglutd.lib' and removing the former from the dependencies, but I'm just curious why it's behaving this way.

Speaking of Additional Dependencies, is adding opengl32.lib actually necessary? I can compile my (very basic) program without it, but more than one person has said it's required, perhaps for older versions of Visual Studio?

Answer

Steve Shi picture Steve Shi · Sep 29, 2015

if you check the freeglut_std.h (freeglut V3.0):

            /* Link with Win32 shared freeglut lib */
#           if FREEGLUT_LIB_PRAGMAS
#               ifdef NDEBUG
#                   pragma comment (lib, "freeglut.lib")
#               else
#                   pragma comment (lib, "freeglutd.lib")
#               endif
#           endif

so if you don't define NDEBUG, the linker will link to "freeglutd.lib", you can solve that by defining a NDEBUG in "PreprocessorDefinitions". Good luck!