C++ 如何修复此错误:#include <gl/glut.h>“无法打开源文件 gl/glut.h”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10467473/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to fix this Error: #include <gl/glut.h> "Cannot open source file gl/glut.h"
提问by Jay
I was doing some OpenGL programming in C++.
我正在用 C++ 做一些 OpenGL 编程。
This is part of my code:
这是我的代码的一部分:
#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"
How can I fix this?
我怎样才能解决这个问题?
EDIT: I am using Microsoft Visual C++ Express Edition. Sorry forgot to mention it
编辑:我使用的是 Microsoft Visual C++ 速成版。抱歉忘记提及了
回答by Dominic Tancredi
You probably haven't installed GLUT:
你可能还没有安装 GLUT:
- Install GLUT If you do not have GLUT installed on your machine you can download it from: http://www.xmission.com/~nate/glut/glut-3.7.6-bin.zip(or whatever version) GLUT Libraries and header files are ? glut32.lib ? glut.h
- 安装 GLUT 如果您的机器上没有安装 GLUT,您可以从以下位置下载:http: //www.xmission.com/~nate/glut/glut-3.7.6-bin.zip(或任何版本)GLUT 库和头文件是?glut32.lib ? glut.h
Source: http://cacs.usc.edu/education/cs596/OGL_Setup.pdf
资料来源:http: //cacs.usc.edu/education/cs596/OGL_Setup.pdf
EDIT:
编辑:
The quickest way is to download the latest header, and compiled DLLs for it, place it in your system32 folder or reference it in your project. Version 3.7 (latest as of this post) is here: http://www.opengl.org/resources/libraries/glut/glutdlls37beta.zip
最快的方法是下载最新的头文件,并为它编译 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.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
回答by Harrison
If you are using Visual Studio Community 2015 and trying to Install GLUT you should place the header file glut.h
in
C:\Program Files (x86)\Windows Kits\8.1\Include\um\gl
如果您使用的是 Visual Studio Community 2015 并尝试安装 GLUT,则应将头文件glut.h
放在
C:\Program Files (x86)\Windows Kits\8.1\Include\um\gl
回答by Mukul Kumar
Visual Studio Community 2017
Visual Studio 社区 2017
Go here :
C:\Program Files (x86)\Windows Kits\10
到这里 :
C:\Program Files (x86)\Windows Kits\10
and do whatever you were supposed to go in the given directory for VS 13.
并在VS 13的给定目录中执行您应该执行的任何操作。
in the lib folder, you will find some versions, I copied the 32-bit glut.libfiles in amdand x86and 64-bit glut.libin arm64and x64directories in um
folder for every version that I could find.
lib文件夹中,你会发现一些版本中,我复制了32位glut.lib文件在AMD和86和64位glut.lib在arm64和64位目录中um
的文件夹为每个版本,我能找到。
That worked for me.
那对我有用。
EDIT : I tried this in windows 10, maybe you need to go to C:\Program Files (x86)\Windows Kits\8.1
folder for windows 8/8.1.
编辑:我在 windows 10 中试过这个,也许你需要转到windows 8/8.1 的C:\Program Files (x86)\Windows Kits\8.1
文件夹。
回答by Farzane
Here you can find every thing you need:
在这里你可以找到你需要的一切:
http://web.eecs.umich.edu/~sugih/courses/eecs487/glut-howto/#win
http://web.eecs.umich.edu/~sugih/courses/eecs487/glut-howto/#win
回答by F?rid Alijani
Try to change #include <gl/glut.h>
to #include "gl/glut.h"
in Visual Studio 2013.
尝试在 Visual Studio 2013 中更改#include <gl/glut.h>
为#include "gl/glut.h"
。