freeglut error LNK1104
Asked Answered
V

2

5

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

I used Premake to generate build files for vs2010. Then I built all libraries (debug). In my project I set Additional Include Directories, Additional Library Directories for the freeglut. In additional dependencies I added freeglutD.lib.

In the code I just include a freeglut header. When I want to run the program I get an error:

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

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

Earlier I was using freeglut 2.8.0 MSVC Package from link which is linked dynamically (contain freeglut.dll) and everything works fine.

What is wrong ?

Variegated answered 14/8, 2012 at 14:20 Comment(0)
T
4

My guess is that you forgot these lines from the documentation on using the SDK:

You will also need to add some #defines to your command line. These are:

  • FREEGLUT_STATIC
  • _LIB
  • FREEGLUT_LIB_PRAGMAS=0

You need that FREEGLUT_STATIC to let GLUT know that it's linking statically. Otherwise it looks for a DLL.

Thickleaf answered 25/8, 2012 at 11:54 Comment(1)
Thanks Jason, FREEGLUT_STATIC solved my linker errors; additionally I also had to give -lgdi32 and -lwinmm which seem to be required for statically linking FreeGLUT in a MinGW setup (transmissionzero.co.uk/computing/using-glut-with-mingw).Particularize
M
1

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

Install-Package freeglut

Note, that I have reference to glew.h and freeglut.h in one of my header files like this:

#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" 
Mark answered 21/11, 2015 at 14:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.