A family of Microsoft suites of integrated development tools for building applications for Windows, the web, mobile devices and many other platforms. Miscellaneous topics that do not fit into specific categories.
gl.h and glut.h are header files, so they do not belong in the linker input. The linker needs .lib files, while headers must be found through the compiler include search path.
For OpenGL on Windows:
- Include the correct headers in code:
- Core OpenGL:
#include <GL\gl.h> - GLU:
#include <GL\glu.h> - WGL/Windows support:
#include <Windows.h>
- Core OpenGL:
- Fix the include path in Visual Studio:
- Open Project Properties.
- Go to Configuration Properties > VC++ Directories > Include Directories.
- Add the parent include folder, not the
GLfolder itself if the code uses#include <GL\...>. - Example: if headers are under
c:\freeglut-3.8.0\include\GL, addc:\freeglut-3.8.0\include.
- Use the include directive that matches the search path:
- If the include directory is
c:\freeglut-3.8.0\include, use#include <GL\gl.h>and#include <GL\glut.h>. - Do not add part of the path twice. If
...\includeis already in Include Directories,#include <GL\glut.h>is correct;#include <include\GL\glut.h>would fail.
- If the include directory is
- Fix the linker settings:
- Remove
glut.handgl.hfrom linker input. - In Configuration Properties > Linker > General > Additional Library Directories, add the folder that contains the
.libfiles. - In Configuration Properties > Linker > Input, add the actual library filenames, not headers.
- Remove
- If building from the Developer Command Prompt, verify environment paths:
- Check
INCLUDE,LIB, andLIBPATH. - If a library or SDK was installed recently, open a new Developer Command Prompt so updated environment variables are picked up.
- Check
- If using vcpkg, it can automate installation and setup for many third-party libraries. That is often easier than manually wiring include and library paths.
The current error is caused by treating header files as linker inputs. The compiler finds headers through Include Directories or /I; the linker finds .lib files through Library Directories or /LIBPATH.