我收到错误:
致命错误:GL / gl.h:没有此类文件或目录编译终止
我不知道为什么,因为我执行以下命令:
sudo apt-get install libgl1-mesa-dev libglu1-mesa-dev freeglut3-dev mesa-common-dev
并在看到错误后,执行以下命令:
sudo apt-get install libglu1-mesa-dev -y
但它仍然显示错误。
我的操作系统:**ubuntu16.06**
我使用!g++ test.cpp -lGLFW -lglfw3 -lGL -lX11 -lXrandr -lXi
错误是:
在/usr/local/include/GLFW/glfw3.h:153:0中包含的文件中, 来自test.cpp:2:
/usr/include/GL/gl.h:6:29:致命错误:GLES / glplatform.h:没有这样的文件或目录
编译终止。
我的测试代码:
#include<cstdio>
#include<cstdlib>
#include<GLFW/glfw3.h>
#include<GL/glew.h>
using namespace std;
int main()
{
if(!glfwInit())
{
fprintf(stderr, "Failed to initialize GLFW\n");
return -1;
}
glfwWindowHint(GLFW_SAMPLES, 4);
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
GLFWwindow* window = glfwCreateWindow(1024, 768, "Tutorial 01", NULL, NULL);
if(window==NULL)
{
fprintf(stderr, "Failed to open GLFW window. If you have an Inter GPU, they ar not 3.3 compatible. Try the 2.1 version of the tutorials.\n");
glfwTerminate();
return -1;
}
int width, height;
glfwGetFramebufferSize(window, &width, &height);
glViewport(0,0,width,height);
while(!glfwWindowShouldClose(window))
{
glfwPollEvents();
glClearColor(0.2f,0.3f,0.3f,1.0f);
glClear(GL_COLOR_BUFFER_BIT);
glfwSwapBuffers(window);
}
glfwTerminate();
return 0;
}