首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何修复此错误:#include <gl/gn.h>“无法打开源文件gl/gn.h”

如何修复此错误:#include <gl/gn.h>“无法打开源文件gl/gn.h”
EN

Stack Overflow用户
提问于 2012-05-06 09:50:08
回答 5查看 145K关注 0票数 22

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

这是我的代码的一部分:

代码语言:javascript
复制
#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++速成版。对不起,我忘了说了。

EN

回答 5

Stack Overflow用户

回答已采纳

发布于 2012-05-06 09:53:00

您可能还没有安装GLUT:

  1. 安装GLUT如果您的计算机上没有安装GLUT,可以从以下位置下载:http://www.xmission.com/~nate/glut/glut-3.7.6-bin.zip (或其他版本) GLUT库和头文件是·glut32.lib·Glu.h

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

编辑:

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

代码语言:javascript
复制
Folder references:

glut.h: 'C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\GL\'
glut32.lib: 'C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib\'
glut32.dll: 'C:\Windows\System32\'

For 64-bit machines, you will want to do this.
glut32.dll: 'C:\Windows\SysWOW64\'

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

Reprinted from here

票数 25
EN

Stack Overflow用户

发布于 2016-10-13 22:22:32

如果您正在使用Visual Studio Community 2015并尝试安装GLUT,则应该将头文件glut.h放在C:\Program Files (x86)\Windows Kits\8.1\Include\um\gl

票数 6
EN

Stack Overflow用户

发布于 2017-09-25 21:26:44

Visual Studio社区2017

点击此处:C:\Program Files (x86)\Windows Kits\10

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

在lib文件夹中,您可以找到一些版本,我将32位glut.lib文件复制到中,并将x86以及64位glut.lib复制到arm64x64目录下的um文件夹中,以获取我能找到的每个版本。

这对我很管用。

编辑:我在Windows10下试过了,也许你需要进入Windows8/8.1C:\Program Files (x86)\Windows Kits\8.1文件夹。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10467473

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档