Freeglut error LNK1104

In my project, I want to use the freeglut library from the unofficial opengl sdk.

I used Premake to create build files for vs2010. Then I built all the libraries (debug). In my project, I installed additional Include directories, additional library directories for freeglut. In additional dependencies, I added freeglutD.lib.

In the code, I simply include the freeglut header. When I want to run the program, I get an error message:

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

FreeglutD.lib is the only file in sdk/freeglut/lib . There is no freeglut.dll and freeglut.lib in sdk.

I used to use the freeglut 2.8.0 MSVC Package from a link that is dynamically linked (contains freeglut.dll), and everything works fine.

What's wrong?

+4
source share
2 answers

I assume that you forgot these lines from the documentation for using the SDK:

You also need to add some #defines to your command line. It:

  • FREEGLUT_STATIC
  • _LIB
  • FREEGLUT_LIB_PRAGMAS = 0

You will need FREEGLUT_STATIC so that GLUT knows that it binds statically. Otherwise, it is looking for a DLL.

+4
source

I had an older project from VS12 and got the same LNK1104 error when trying to create it after updating in VS15. All I had to do to fix this was the Package Manager Console (Tools - NuGet Package Manager), and type:

 Install-Package freeglut 

Note that I have a link to glew.h and freeglut.h in one of my header files, for example:

 #include "..\packages\nupengl.core.0.1.0.1\build\native\include\GL\glew.h" #include "..\packages\nupengl.core.0.1.0.1\build\native\include\GL\freeglut.h" 
0
source

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


All Articles