如何修复此错误:#include < gl/glut.h> "Cannot open source file gl/glut.h"

How to fix this Error: #include <gl/glut.h> "Cannot open source file gl/glut.h"

本文关键字:glut gl Cannot 何修复 open source file gt #include 错误 lt      更新时间:2023-10-16

我在C++做一些OpenGL编程。

这是我代码的一部分:

#include <time.h>
#include <windows.h>
#include <gl/gl.h>
#include <gl/glu.h>
#include <gl/glut.h> <<< Error here "Cannot open source file gl/glut.h"

我该如何解决这个问题?

编辑:我正在使用Microsoft Visual C++ Express Edition。对不起,忘了提了

您可能尚未安装 GLUT:

  1. 安装 GLUT如果您的机器上没有安装 GLUT,您可以从以下位置下载:http://www.xmission.com/~nate/glut/glut-3.7.6-bin.zip(或任何版本)GLUT 库和头文件是• glut32.lib• 过剩

来源: http://cacs.usc.edu/education/cs596/OGL_Setup.pdf

编辑:

最快的方法是下载最新的标头和编译的 DLL,将其放在 system32 文件夹中或在项目中引用它。版本 3.7(截至本文的最新)在这里:http://www.opengl.org/resources/libraries/glut/glutdlls37beta.zip

Folder references:
glut.h: 'C:Program Files (x86)Microsoft Visual Studio 10.0VCincludeGL'
glut32.lib: 'C:Program Files (x86)Microsoft Visual Studio 10.0VClib'
glut32.dll: 'C:WindowsSystem32'
For 64-bit machines, you will want to do this.
glut32.dll: 'C:WindowsSysWOW64'
Same pattern applies to freeglut and GLEW files with the header files in the GL folder, lib in the lib folder, and dll in the System32 (and SysWOW64) folder.
1. Under Visual C++, select Empty Project.
2. Go to Project -> Properties. Select Linker -> Input then add the following to the Additional Dependencies field:
opengl32.lib
glu32.lib
glut32.lib

转载自这里

如果您使用的是Visual Studio Community 2015并尝试安装GLUT并且应该将头文件放在glut.h C:Program Files (x86)Windows Kits8.1Includeumgl

Visual Studio Community 2017

去这里 : C:Program Files (x86)Windows Kits10

并在 VS 13 的给定目录中执行任何您应该执行的操作。

在 lib 文件夹中,您会找到一些版本,我复制了 amd 中的 32 位 glut.lib 文件以及 arm64 和 x64 目录中的 x64 和 x64位 glut.lib um我能找到的每个版本。

这对我有用。

编辑:我在Windows 10中尝试过这个,也许您需要转到Windows 8/8.1C:Program Files (x86)Windows Kits8.1文件夹。

在这里你可以找到你需要的一切:

http://web.eecs.umich.edu/~sugih/courses/eecs487/glut-howto/#win

尝试在Visual Studio 2013中将#include <gl/glut.h>更改为#include "gl/glut.h"