簡體   English   中英

如何解決此錯誤:#include <gl/glut.h> “無法打開源文件gl / glut.h”

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

我在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。 對不起忘了提它

您可能沒有安裝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

從這里轉載

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

Visual Studio社區2017

轉到此處: C:\\Program Files (x86)\\Windows Kits\\10

並在VS 13的給定目錄中執行您應該執行的任何操作。

在lib文件夾中,你會發現一些版本,我復制了amdx86中32位glut.lib文件和arm64中的64位 glut.lib以及我可以找到的每個版本的um文件夾中的x64目錄。

這對我有用。

編輯:我在Windows 10中試過這個,也許你需要轉到Windows 8 / 8.1的 C:\\Program Files (x86)\\Windows Kits\\8.1文件夾。

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

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