2012-05-06 28 views
14

我在C++中做了一些OpenGL編程。如何解決這個錯誤:#include <gl/glut.h>「Can not open source file gl/glut.h」

這是我的代碼部分:

#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++速成版。對不起忘了提到它

+1

你需要的,如果我沒有記錯它不是在Windows的OpenGL –

+0

@JesusRamos包括默認安裝GLUT如何安裝呢? – Jay

+0

@Jay http://freeglut.sourceforge.net/ – birryree

回答

19

您可能還沒有安裝GLUT:

  1. 如果你沒有在計算機上安裝GLUT你可以從這裏下載安裝GLUT : http://www.xmission.com/~nate/glut/glut-3.7.6-bin.zip(或者其他版本) GLUT庫和頭文件 •glut32.lib •glut.h

來源: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

+0

是否有任何有關Microsoft Visual C++ Express Edition的說明 – Jay

+0

已更新我的帖子,希望能夠爲您提供從其他站點重新打印的更好的說明。 –

+0

舊但是:它沒有必要以這種方式污染System32或SysWOW64文件夾。只需將頭文件和庫文件放置在硬盤上的任意位置的文件夾中,然後將該文件夾添加到項目的包含目錄和庫目錄中。這裏有一個很好的教程,其中包含一些關於如何執行此操作的圖片:http://blogs.msdn.com/b/vsproject/archive/2009/07/07/vc-directories.aspx –

3

如果您正在使用Visual Studio Community 2015並嘗試安裝GLUT,則應將頭文件glut.h放入 C:\Program Files (x86)\Windows Kits\8.1\Include\um\gl

-1

嘗試在Visual Studio中改變#include <gl/glut.h>到2013年#include "gl/glut.h"

0

的Visual Studio 2017年社區

去這裏: C:\Program Files (x86)\Windows Kits\10

,做任何你應該在給定的目錄去VS 13

lib文件夾中

,你會發現一些版本中,我複製了32位glut.lib文件AMD和和64位glut.libarm64x64目錄在um文件夾爲我能找到的每個版本。

這對我有用。

編輯:我試過在Windows 10中,也許你需要去C:\Program Files (x86)\Windows Kits\8.1文件夾爲窗口8/8.1