Why is Visual Studio trying to bind "freeglutd.lib"?

I am trying to compile an OpenGL program using Visual Studio 2013, but I am getting the following error:

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

For reference, I have FreeGLUT installed and configured VS to search for the correct directories for included files and library files. Indeed, VS recognizes that GLUT includes files just fine. I also added opengl32.lib and freeglut.lib to additional dependencies.

Why is VS looking for "freeglutd.lib"? It is definitely not listed in the additional dependencies. I can solve the compilation error by renaming "libglut.lib" to "libglutd.lib" and removing the first of the dependencies, but I'm just curious why it behaves this way.

Speaking of additional dependencies, is it really necessary to add opengl32.lib? I can compile my (very basic) program without it, but more than one person has stated that this is necessary, perhaps for older versions of Visual Studio?

+5
source share
4 answers

Perhaps already answered: freeglut error LNK1104

You also need to check two things:

  • Do you work in debug or release mode? d at the end of freeglutd.lib assumes this is a library for debugging builds
  • Try to create a new project from scratch, add some basic executable code to it that uses freeGLUT and see if VS communicates correctly. It will also check for any reason the project file of the previous project was corrupted (as @RobertHarvey suggested) or the problem is somewhere else.
+1
source

if you checked 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 

therefore, if you do not define NDEBUG, the linker will reference "freeglutd.lib", you can solve this by specifying NDEBUG in "PreprocessorDefinitions". Good luck

+4
source

I solved this problem by compiling freeglut and freeglut_static from the generated CMake soluton in Debug mode - freeglutd was created in the lib / Debug directory. You can put this directory in the lib path and it will work!

0
source

Hey, I don’t know if you have this error, but here is the solution. To a large extent, "freeglutd.lib" has to do with debugging, hence the "d" at the end, so I did this:

Property> C / C ++> Preprocessor> Preprocessor Definitions and enter NDEBUG. Then OK and Apply .

What this does in "freeglut_std.h" is ifdef for NDEBUG, if it is defined, then use "freeglut.lib", otherwise it will use "freeglutd.lib". Therefore, by defining it in the preprocessor definitions, you are now using "freeglut.lib". Hope this helps you!

0
source

Source: https://habr.com/ru/post/1215563/


All Articles