C++ OPENgl - GL/glut.h 没有这样的文件或目录

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19858072/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-27 23:12:30  来源:igfitidea点击:

OPENgl - GL/glut.h no such file or directory

c++opengl

提问by Siddharth Taunk

can any one help me with the following error

任何人都可以帮助我解决以下错误

GL/glut.h no such file or directory

GL/glut.h 没有这样的文件或目录

The things I did are

我做的事情是

  1. After installation of MinGW i have added the Path to the path enviornment variable
  2. Added 'glut.h' to C:\MinGW\Include\GL
  3. Added glut32.dll to C:\Windows\SysWOW64
  4. Added glut32.lib to the project folder
  5. COmpiled with 'g++ -o hello.exe -Wall hello.c glee.lib glut32.lib -lopengl32 -lglu32'
  1. 安装 MinGW 后,我已将 Path 添加到路径环境变量中
  2. 将“glut.h”添加到 C:\MinGW\Include\GL
  3. 将 glut32.dll 添加到 C:\Windows\SysWOW64
  4. 将 glut32.lib 添加到项目文件夹
  5. 用'g++ -o hello.exe -Wall hello.c glee.lib glut32.lib -lopengl32 -lglu32'编译

and still the error above persist please help

仍然上面的错误仍然存​​在请帮助

#include<GL/glut.h>
#include<iostream>
//#include<conio.h>

void render(void);

void keyboard(unsigned char c, int x, int y);

void mouse(int button, int state, int x, int y);

int main(int argc, char** atgv)
{
glutInit(&argc, argv);
glutInitDisplayMode( GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
glutInitWindowPosition(100, 100);
glutInitWindowSize(640, 480);
glutCreateWindow("Sample GLUT Application");

glutDisplayFunc(render);
glutKeyboardFunc(keyboard);
glutMouseFunc(mouse);

glutMainLoop();
}

void keyboard(unsigned char c, int x, int y)
{
if(c == 27){
    exit(0);
    }
}

void mouse(int button, int state, int x, int y)
{
if(button == GLUT_RIGHT_BUTTON )
{
    exit(0);
}
}

void render(void)
{   
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );

glBegin(GL_TRIANGLES);
    glColor3f(1, 0, 0);
    glVertex2f(-0.5, -0.5);
    glColor3f(0, 1, 0);
    glVertex2f(0.5, -0.5);  
    glColor3f(0, 0, 1);
    glVertex2f(0.0, 0.5);
glEnd();

glutSwapBuffers();
}

回答by GMasucci

some simple things that can cause problems in my experience (so make sure they are set!:) :

一些简单的事情可能会导致我的经验出现问题(所以请确保它们已设置!:):

  • check to see if C:\MinGW\binis in your path variable if not, add C:\MinGW\binto your PATH (type %path% in a console window to ensure the path property is applied to the window console session you are using)
  • put glut32.dllinto C:\windows\system32so it can be located at runtime, or place it in the same directory as the executable you wish to run
  • Just checked and my minGW has glut32.dllin c:\mingw\bin
  • and libglut32.ain c:\mingw\lib
  • and glut.hshould be in c:\mingw\include\GL
  • 检查是否C:\MinGW\bin在您的路径变量中,如果没有,请添加C:\MinGW\bin到您的 PATH(在控制台窗口中键入 %path% 以确保路径属性应用于您正在使用的窗口控制台会话)
  • glut32.dllC:\windows\system32这样它可以位于在运行时,或将其放置在同一目录下,你想运行的可执行
  • 刚检查过,我的 minGW 已glut32.dllc:\mingw\bin
  • libglut32.ac:\mingw\lib
  • 并且glut.h应该在c:\mingw\include\GL

Apologies for the previous omission.

为之前的疏忽道歉。

That should see you alright provided there are no other issues at play.

如果没有其他问题在起作用,那应该可以看到您。

Let me know if you need more info/help :)

如果您需要更多信息/帮助,请告诉我:)

Addendum:

附录:

I located this linkwhich whilst old may be of use to you in making the files available to mingw's environment.

我找到了这个链接,虽然很旧,但它可能对您在使文件可用于 mingw 的环境中有用。