简体   繁体   English

如何解决此错误:#include <gl/glut.h> “无法打开源文件gl / glut.h”

[英]How to fix this Error: #include <gl/glut.h> “Cannot open source file gl/glut.h”

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. 编辑:我正在使用Microsoft Visual C ++ Express Edition。 Sorry forgot to mention it 对不起忘了提它

You probably haven't installed GLUT: 您可能没有安装GLUT:

  1. 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. 最快的方法是下载最新的头文件,并为其编译DLL,将其放在system32文件夹中或在项目中引用它。 Version 3.7 (latest as of this post) is here: http://www.opengl.org/resources/libraries/glut/glutdlls37beta.zip 版本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

Reprinted from here 从这里转载

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

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.lib files in amd and x86 and 64-bit glut.lib in arm64 and x64 directories in um folder for every version that I could find. 在lib文件夹中,你会发现一些版本,我复制了amdx86中32位glut.lib文件和arm64中的64位 glut.lib以及我可以找到的每个版本的um文件夹中的x64目录。

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文件夹。

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM