首页 > 解决方案 > Windows下编译OpenGL代码出错

问题描述

我正在尝试编译一个 OpenGL 程序。

这是包含所有内容的代码部分:

#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <GL/glew.h>
#include <GL/glut.h>
// Usage of degrees is deprecated. Use radians for glm functions.
#define GLM_FORCE_RADIANS
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include "shaders.h"

我试图运行的文件被调用mytest1.cpp,我也在shaders.h同一个目录中。

在同一个目录中,我有一个名为'include'And 的文件夹,其中包含两个名为 And 的子文件夹'GL''glm'其中包含程序所需的所有文件。

所以我转到目录mytest1.cpp并输入g++ mytest1.cpp,我得到错误:

mytest1.cpp:14:21: fatal error: GL/glew.h: No such file or directory
 #include <GL/glew.h>
                     ^
compilation terminated.

为什么会这样?我也尝试将'GL'文件夹放在根目录中,我得到了同样的错误

标签: c++openglcompiler-errorscompilationg++

解决方案


推荐阅读