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

18,489

Solution 1

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!

Solution 2

Hey man I don't know if you're still having this error but here is a solution. Pretty much the "freeglutd.lib" has to do with debugging, hence the "d" on the end, so what I did was go into the:

Properties > C/C++ > Preprocessor > Preprocessor Definitions and type NDEBUG. Then OK and Apply.

What this does is in the "freeglut_std.h" there is a ifdef for NDEBUG that if it is defined then use "freeglut.lib" otherwise it's going to use the "freeglutd.lib". So by defining it in the Preprocessor Definitions, you are now using the "freeglut.lib". Hopefully this helps you out!

Solution 3

Possibly already answered: freeglut error LNK1104

Also two things to check for:

  • Are you building in debug or release mode? The d at the end of freeglutd.lib suggests that it's a library meant for debug builds
  • Try creating a new project from scratch, put some basic runnable code in it that uses freeGLUT and see if VS is linking properly. This will also verify if for some reason the project file of the previous project was corrupted (as @RobertHarvey suggested) or the problem is somewhere else
Share:
18,489

Related videos on Youtube

someguy
Author by

someguy

Updated on September 16, 2022

Comments

  • someguy
    someguy over 1 year

    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?

    • someguy
      someguy about 9 years
      @Robert Harvey: I searched the entire solution for libglutd.lib and freeglutd.lib (I guess that's what you meant) but nothing was found. Edit: I checked the log file as well, and the link command doesn't have 'freeglutd.lib' as a library.
  • someguy
    someguy about 9 years
    I looked at that answer before and it didn't help unfortunately. I tried both debug and release mode. I also did as you suggested and created a new project, but no luck.
  • rbaleksandar
    rbaleksandar about 9 years
    Hmm, interesting. Btw I just so the end of your question - yes, opengl is needed as a dependency because freeGLUT uses OpenGL but covers some of its complexity (window creation, input event handling, initialisation of OpenGL stuff etc. Can you post a screen shot of your project settings (linking dependencies, headers etc.). OpenGL does not require freeGLUT but I have the feeling that you are writing OpenGL code from somewhere, where freeGLUT is used instead of pure OpenGL hence the dependency on freeGLUT.
  • someguy
    someguy about 9 years
    I just realised I wasn't applying the suggestion from the linked answer properly. I defined those macros after including GL/glut.h, which is pointless. I can now say the problem is with FREEGLUT_LIB_PRAGMAS being equal to 1. More specifically, if it is equal to 1, GL/freeglut_std.h will try to link libglutd.lib if NDEBUG is not defined. So it is meant for debug builds, but Release mode doesn't define NDEBUG by default. PS upon inspection of the glut header file, opengl32.lib is linked for you if FREEGLUT_LIB_PRAGMAS is 1.
  • Morse
    Morse about 6 years
    Please use formatting tools to properly edit and format your answer. Codes within sentences are to be formatted as code Very Important words to be bold , less important onces Italic