[英]No OpenGL 3 headers in Arch Linux
我正在嘗試使用FreeGLUT編譯一個非常簡單的“Hello world”OpenGL 3.3程序。 在我發現的所有教程中,它們都包含一個標題“gl3.h”。 問題是,我沒有這樣的頭文件。
$ ls -l /usr/include/GL/
total 2164
-rw-r--r-- 1 root root 8797 20 janv. 17:44 freeglut_ext.h
-rw-r--r-- 1 root root 681 20 janv. 17:44 freeglut.h
-rw-r--r-- 1 root root 26181 20 janv. 17:44 freeglut_std.h
-rw-r--r-- 1 root root 837247 27 janv. 12:55 glew.h
-rw-r--r-- 1 root root 656589 21 mars 18:07 glext.h
-rw-r--r-- 1 root root 84468 21 mars 18:07 gl.h
-rw-r--r-- 1 root root 128943 21 mars 18:07 gl_mangle.h
-rw-r--r-- 1 root root 17255 21 mars 18:07 glu.h
-rw-r--r-- 1 root root 3315 21 mars 18:07 glu_mangle.h
-rw-r--r-- 1 root root 639 20 janv. 17:44 glut.h
-rw-r--r-- 1 root root 62741 27 janv. 12:55 glxew.h
-rw-r--r-- 1 root root 43887 21 mars 18:07 glxext.h
-rw-r--r-- 1 root root 17170 21 mars 18:07 glx.h
-rw-r--r-- 1 root root 4706 3 févr. 13:33 glxint.h
-rw-r--r-- 1 root root 3463 21 mars 18:07 glx_mangle.h
-rw-r--r-- 1 root root 2086 3 févr. 13:33 glxmd.h
-rw-r--r-- 1 root root 80979 3 févr. 13:33 glxproto.h
-rw-r--r-- 1 root root 11246 3 févr. 13:33 glxtokens.h
drwxr-xr-x 2 root root 4096 14 avril 14:03 internal
-rw-r--r-- 1 root root 8497 21 mars 18:07 osmesa.h
-rw-r--r-- 1 root root 51274 21 mars 18:07 vms_x_fix.h
-rw-r--r-- 1 root root 59403 27 janv. 12:55 wglew.h
-rw-r--r-- 1 root root 41377 21 mars 18:07 wglext.h
-rw-r--r-- 1 root root 4468 21 mars 18:07 wmesa.h
在/usr/include/
我只有GL
, GLES
和GLES2
。 我在一些教程中找不到GL3
。
我使用NVIDIA顯卡( nvidia
閉源驅動程序)在Arch Linux x86_64上運行。
以下是我在程序中包含OpenGL和FreeGLUT API的方法:
#define GL3_PROTOTYPES 1
#include <GL/gl.h>
#include <GL/freeglut.h>
但是代碼沒有編譯:
$ g++ -pipe -g -Wall -Wextra -pedantic -I. -IHeaders -c Sources/Main.cpp -o Temp/Objects/Main.o
Sources/Main.cpp: In function ‘int main(int, char**)’:
Sources/Main.cpp:107:59: error: ‘glVertexAttribPointer’ was not declared in this scope
Sources/Main.cpp:108:30: error: ‘glEnableVertexAttribArray’ was not declared in this scope
Sources/Main.cpp:114:35: error: ‘glUseProgram’ was not declared in this scope
Sources/Main.cpp:138:31: error: ‘glDisableVertexAttribArray’ was not declared in this scope
好像我加入了OpenGL 2標題! 但是,再次,我沒有在我的系統上找到任何OpenGL 3標頭,我查看了Arch存儲庫和AUR,但沒有成功。
謝謝您的幫助!
你不需要GL3.h,GL3.h只是擺脫了所有棄用的功能。 所以只需要包含gl.h
而不是gl3.h
下載和手動copyieng到/usr/include/GL/
不是一個真正的解決方案,它的工作原理是肯定的,但是如果添加到mesa
包中的gl3.h
怎么gl3.h
? 你是包經理會發現沖突。 最好將gl3.h
添加到項目或主目錄中,並將其添加到$ PATh或使用-I標志。
如果你grep
glVertexAttribPointer,glEnableVertexAttribArray,glUseProgram和glDisableVertexAttribArray,你會發現它們包含在glext.h
和glew.h
。 嘗試包含其中一個標題並再次編譯。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.