VS2008無法打開gl/glaux.h頭文件的解決方法

不知道爲什麼到VS2008後,SDK中沒有OpenGL的頭文件了,下面針對這個問題總結一下。

 

在學習NeHe的紋理映射的Lesson 6中,開始需要用到包含gl/glaux.h的頭文件,但是發現在我的系統中並沒有這個頭文件。並發現編譯器中引用OpenGL的頭文件路徑有兩個:
C:/Program Files/Microsoft SDKs/Windows/v6.0A/include/gl/gl.h            (默認的)
C:/Program Files/Microsoft Visual Studio 9.0/VC/include/gl/glut.h           (自己手動新建的GL文件夾)

在網上google了一下解決辦法。

方法1:找到用的最多的解決方法,但是我的系統中沒有事先安裝VS2003或VS2005,因此無法拷貝。
I have been porting old openGL program to VS2008. I have solved the problem by copying the "include/gl/glaux.h" and "lib/glaux.lib" from the VS2005 Platform SDK located on "C:/Program Files/Microsoft Visual Studio 8/VC/PlatformSDK" to the Platform SDK of VS2008 located on "C:/Program Files/Microsoft SDKs/Windows/v6.0A"

方法2:網頁沒打開,做個標記。
Based on the reply to https://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1065518&SiteID=1, it looks like glaux.lib is deprecated. Instead link to kernel32.lib, user32.lib, gdi32.lib and advapi32.lib

方法3:直接使用glut工具包,我在VS2008上試了一下不行,報同樣的錯誤。
The easiest way to sort this out is to:
1) install glut 3.6 or newer as directed.
2) Open Visual studio 2008 and create a new project
3) choose c++ - empty solution
4) import all the files from your previous OpenGL project
5) delete all headers i.e.
#include <gl/glu.h>
#include <gl/gluax.h>
and any other GL headers
6) then replace with #include <gl/glut.h>
7) recompile.

this worked for all of my 2003 & 2005 solutions.

方法4:下載缺少的文件。
下載源1:CSDN下載
OpenGL 安裝包所需文件下載:
http://d.download.csdn.net/down/2560229/ssagnn23
包括:
GL.H   GLAUX.H   GLU.H   glut.h  
GLAUX.LIB   GLU32.LIB   glut32.lib   glut.lib   OPENGL32.LIB
glaux.dll   glu32.dll   glut32.dll   glut.dll   opengl32.dll

VS2008不帶 GL.H, GLAUX.h, glu.h, glaux.lib, glu32.lib, opengl32.lib 這些文件。通過上面所給地址下載後,把下載的文件分配放在系統中不同的文件夾下,具體配置方法如下:

(1) 把 glaux.dll、glut32.dll、glut.dll 拷貝到C:/WINDOWS/system32目錄下,system32目錄下應該已經有 opengl32.dll、glu32.dll了。
(2) 把 GL.H、GLAUX.h、glu.h、glut.h  拷貝到 C:/Program Files/Microsoft Visual Studio 9.0/VC/include/gl
(3) 把 GLAUX.LIB、Glu32.lib、glut32.lib、Opengl32.lib,glut.lib 拷貝到 C:/Program Files/Microsoft Visual Studio 9.0/VC/lib

下載源2:
nehe-src-cn —— Nehe的OpenGL教程中文版及代碼下載
http://code.google.com/p/nehe-src-cn/downloads/list
Nehe的OpenGL教程中文版及代碼下載
http://www.yakergong.com/nehe/
提供了每個Lesson的示例代碼以及所需要的文件。

按照方法4,下載完文件並配置後好,重新編譯,以前的錯誤沒有了,說明文件找到了,但又出現下面這個錯誤。
error C2664: “auxDIBImageLoadW”: 不能將參數 1 從“char *”轉換爲“LPCWSTR”
這個是因爲我建立的是基於unicode字符集的工程,所以要使用寬字符。也可以不使用unicode字符集,在屬性頁->配置屬性->常規裏修改即可。此處選擇不使用unicode字符集,即,選擇未設置。然後再重新編譯,ok!

注意:Debug版本和Release版本要分別設置字符集。


參考
missing glaux.h in v6.0a sdk?
http://social.msdn.microsoft.com/Forums/en/windowssdk/thread/b66e5f7a-91f6-4dbe-b388-0c131008b08f
VS2003下的項目在VS2008下編譯不過,找不到gl/glaux.h
http://topic.csdn.net/u/20070930/15/6a900f21-8e41-4325-862f-f6df3a425f36.html
VS 2008 OpenGL 配置
http://lujun5918.blog.163.com/blog/static/287227712011013114410553/
opengl中載入圖片生成紋理的程序
http://topic.csdn.net/u/20070823/19/4497cb18-be2a-464f-ad20-b12191a61b26.html



轉載自:http://blog.csdn.net/delphiwcdj/article/details/6326586


發佈了9 篇原創文章 · 獲贊 8 · 訪問量 14萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章