为什么这个GLUT程序不能编译?我是否缺少库或标头? [英] Why won't this GLUT program compile? Am I missing libraries or headers?

查看:115
本文介绍了为什么这个GLUT程序不能编译?我是否缺少库或标头?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始使用Linux(Mint 11),最近,我决定将OpenGL编程作为一种爱好.我发现代码和技术相对简单,但是,很难在正确的位置获取所有资源.代码是:

I've just started using Linux (Mint 11), and recently, I decided to take up OpenGL programming as a hobby. I'm finding the code and techniques relatively simple enough, however, I'm having a hard time trying to get all the resources in the right place. The code is:

#include <stdlib.h>
#include <stdio.h>
#include <GL/glew.h>
#ifdef __APPLE__
#  include <GLUT/glut.h>
#else
#  include <GL/glut.h>
#endif

static int make_resources(void)
{
    return 1;
}

static void update_fade_factor(void)
{
}

static void render(void)
{
    glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
    glClear(GL_COLOR_BUFFER_BIT);
    glutSwapBuffers();
}


int main(int argc, char** argv)
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
    glutInitWindowSize(400, 300);
    glutCreateWindow("Hello World");
    glutDisplayFunc(&render);
    glutIdleFunc(&update_fade_factor);
        glewInit();
    if (!GLEW_VERSION_2_0) {
        fprintf(stderr, "OpenGL 2.0 not available\n");
        return 1;
    }
      if (!make_resources()) {
        fprintf(stderr, "Failed to load resources\n");
        return 1;
    }

    glutMainLoop();
    return 0;
}

编译时,我收到以下消息

When I compile, I get the following messages

../../Libraries/glut-3.7/lib/glut/libglut.so||undefined reference to `glXQueryChannelRectSGIX'|
../../Libraries/glut-3.7/lib/glut/libglut.so||undefined reference to `glXChannelRectSyncSGIX'|
../../Libraries/glut-3.7/lib/glut/libglut.so||undefined reference to `glXChannelRectSGIX'|
../../Libraries/glut-3.7/lib/glut/libglut.so||undefined reference to `glXQueryChannelDeltasSGIX'|
../../Libraries/glut-3.7/lib/glut/libglut.so||undefined reference to `glXBindChannelToWindowSGIX'|
||=== Build finished: 5 errors, 0 warnings ===|

在线查看告诉我,我可能不包括正确的库(大概是libX),但是我不确定在哪里可以找到它们,如果它们甚至是正确使用的库.我已经尝试链接/usr/lib/X86_64-linux-gnu/libX11.so,/usr/lib/X11既不包含库文件也不包含/lib目录,并且我确定已安装lib11-dev软件包.我究竟做错了什么?

Looking online told me that I'm probably not including the right libraries (presumably libX), however I'm unsure of where I can find them, If they're even the right ones to use. I've already tried linking /usr/lib/X86_64-linux-gnu/libX11.so, /usr/lib/X11 contains neither library files nor a /lib directory, and I'm certain that the lib11-dev package is installed. What am I doing wrong?

信息:
操作系统:Linux Mint 11
IDE:代码::块10.05
遵循教程. 注意:我找不到它所指的x11r6目录.

INFO:
OS: Linux Mint 11
IDE: Code::blocks 10.05
Following this tutorial. Note: I cannot find the x11r6 directories it refers to.

推荐答案

请确保您已将libglew-dev和freeglut3-dev安装到

be sure you have installed libglew-dev and freeglut3-dev with

sudo apt-get install libglew-dev freeglut3-dev

,然后链接到您的Makefile中的此库或使用

and then link to this libs in your Makefile or compile command with

-lglut -lGLEE

例如

g++ -lglut -lGLEW -o test main.cpp

(这就是我编译示例的方式)

(this is how I compiled your example)

这篇关于为什么这个GLUT程序不能编译?我是否缺少库或标头?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆