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

时间:2012-05-06 01:50:08

标签: c++ opengl vector matrix

我正在使用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。对不起忘记提及

5 个答案:

答案 0 :(得分:24)

您可能尚未安装GLUT:

  1. 安装GLUT 如果您的计算机上没有安装GLUT,可以从以下位置下载: http://www.xmission.com/~nate/glut/glut-3.7.6-bin.zip(或任何版本) GLUT库和头文件是 •glut32.lib •glut.h
  2. 来源: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.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

答案 1 :(得分:6)

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

答案 2 :(得分:2)

2017年Visual Studio社区

转到此处: C:\Program Files (x86)\Windows Kits\10

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

在lib文件夹中,你会发现一些版本,我在 amd x86 中复制了 32位glut.lib 文件,对于我能找到的每个版本, arm64 中的 64位glut.lib um文件夹中的 x64 目录。

这对我有用。

编辑:我在Windows 10中试过这个,也许您需要转到{{1>} windows 8 / 8.1 的文件夹。

答案 3 :(得分:0)

在这里,您可以找到所需的一切:

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

答案 4 :(得分:-2)

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