• <bdo id='svXnq'></bdo><ul id='svXnq'></ul>
      1. <small id='svXnq'></small><noframes id='svXnq'>

        <i id='svXnq'><tr id='svXnq'><dt id='svXnq'><q id='svXnq'><span id='svXnq'><b id='svXnq'><form id='svXnq'><ins id='svXnq'></ins><ul id='svXnq'></ul><sub id='svXnq'></sub></form><legend id='svXnq'></legend><bdo id='svXnq'><pre id='svXnq'><center id='svXnq'></center></pre></bdo></b><th id='svXnq'></th></span></q></dt></tr></i><div id='svXnq'><tfoot id='svXnq'></tfoot><dl id='svXnq'><fieldset id='svXnq'></fieldset></dl></div>
        <tfoot id='svXnq'></tfoot>

        <legend id='svXnq'><style id='svXnq'><dir id='svXnq'><q id='svXnq'></q></dir></style></legend>

        在 ubuntu 中编译 GLUT 时出错

        时间:2023-09-17
              <tbody id='h2zBw'></tbody>
            • <bdo id='h2zBw'></bdo><ul id='h2zBw'></ul>
              <tfoot id='h2zBw'></tfoot>
            • <legend id='h2zBw'><style id='h2zBw'><dir id='h2zBw'><q id='h2zBw'></q></dir></style></legend>

                  <i id='h2zBw'><tr id='h2zBw'><dt id='h2zBw'><q id='h2zBw'><span id='h2zBw'><b id='h2zBw'><form id='h2zBw'><ins id='h2zBw'></ins><ul id='h2zBw'></ul><sub id='h2zBw'></sub></form><legend id='h2zBw'></legend><bdo id='h2zBw'><pre id='h2zBw'><center id='h2zBw'></center></pre></bdo></b><th id='h2zBw'></th></span></q></dt></tr></i><div id='h2zBw'><tfoot id='h2zBw'></tfoot><dl id='h2zBw'><fieldset id='h2zBw'></fieldset></dl></div>

                1. <small id='h2zBw'></small><noframes id='h2zBw'>

                2. 本文介绍了在 ubuntu 中编译 GLUT 时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我尝试编译一些hello world"glut应用程序:

                  I try to compile some "hello world" glut application:

                  #include <stdlib.h>
                  
                  #include <GL/gl.h>
                  
                  #include <GL/glu.h>
                  
                  #include <GL/glut.h>
                  
                  GLint Width = 512, Height = 512;
                  
                  const int CubeSize = 200;
                  
                  void Display(void)
                  {
                      int left, right, top, bottom;
                  
                      left  = (Width - CubeSize) / 2;
                      right = left + CubeSize;
                      bottom = (Height - CubeSize) / 2;
                      top = bottom + CubeSize;
                  
                      glClearColor(0, 0, 0, 1);
                      glClear(GL_COLOR_BUFFER_BIT);
                  
                      glColor3ub(255,0,0);
                      glBegin(GL_QUADS);
                        glVertex2f(left,bottom);
                        glVertex2f(left,top);
                        glVertex2f(right,top);
                        glVertex2f(right,bottom);
                      glEnd();
                  
                      glFinish();
                  }
                  
                  void Reshape(GLint w, GLint h)
                  {
                      Width = w;
                      Height = h;
                      glViewport(0, 0, w, h);
                  
                      glMatrixMode(GL_PROJECTION);
                      glLoadIdentity();
                      glOrtho(0, w, 0, h, -1.0, 1.0);
                  
                      glMatrixMode(GL_MODELVIEW);
                      glLoadIdentity();
                  }
                  
                  void Keyboard(unsigned char key, int x, int y)
                  {
                  #define ESCAPE '33'
                  
                      if( key == ESCAPE )
                          exit(0);
                  }
                  
                  main(int argc, char *argv[])
                  {
                      glutInit(&argc, argv);
                      glutInitDisplayMode(GLUT_RGB);
                      glutInitWindowSize(Width, Height);
                      glutCreateWindow("Red square example");
                  
                      glutDisplayFunc(Display);
                      glutReshapeFunc(Reshape);
                      glutKeyboardFunc(Keyboard);
                  
                      glutMainLoop();
                  }
                  

                  编译命令为:

                  gcc -lGL -lGLU hw_opengl.cpp -o hw_opengl
                  

                  我有以下错误:

                  /tmp/ccbnBFHC.o: In function `Display()':
                  hw_opengl.cpp:(.text+0x6c): undefined reference to `glClearColor'
                  hw_opengl.cpp:(.text+0x78): undefined reference to `glClear'
                  hw_opengl.cpp:(.text+0x94): undefined reference to `glColor3ub'
                  hw_opengl.cpp:(.text+0xa0): undefined reference to `glBegin'
                  hw_opengl.cpp:(.text+0xb4): undefined reference to `glVertex2f'
                  hw_opengl.cpp:(.text+0xc8): undefined reference to `glVertex2f'
                  hw_opengl.cpp:(.text+0xdc): undefined reference to `glVertex2f'
                  hw_opengl.cpp:(.text+0xf0): undefined reference to `glVertex2f'
                  hw_opengl.cpp:(.text+0xf5): undefined reference to `glEnd'
                  hw_opengl.cpp:(.text+0xfa): undefined reference to `glFinish'
                  /tmp/ccbnBFHC.o: In function `Reshape(int, int)':
                  hw_opengl.cpp:(.text+0x134): undefined reference to `glViewport'
                  hw_opengl.cpp:(.text+0x140): undefined reference to `glMatrixMode'
                  hw_opengl.cpp:(.text+0x145): undefined reference to `glLoadIdentity'
                  hw_opengl.cpp:(.text+0x173): undefined reference to `glOrtho'
                  hw_opengl.cpp:(.text+0x17f): undefined reference to `glMatrixMode'
                  hw_opengl.cpp:(.text+0x184): undefined reference to `glLoadIdentity'
                  /tmp/ccbnBFHC.o: In function `main':
                  hw_opengl.cpp:(.text+0x1c1): undefined reference to `glutInit'
                  hw_opengl.cpp:(.text+0x1cd): undefined reference to `glutInitDisplayMode'
                  hw_opengl.cpp:(.text+0x1e4): undefined reference to `glutInitWindowSize'
                  hw_opengl.cpp:(.text+0x1f0): undefined reference to `glutCreateWindow'
                  hw_opengl.cpp:(.text+0x1fc): undefined reference to `glutDisplayFunc'
                  hw_opengl.cpp:(.text+0x208): undefined reference to `glutReshapeFunc'
                  hw_opengl.cpp:(.text+0x214): undefined reference to `glutKeyboardFunc'
                  hw_opengl.cpp:(.text+0x219): undefined reference to `glutMainLoop'
                  collect2: ld returned 1 exit status
                  

                  我已经安装了 GLUT:sudo apt-get install freeglut3 freeglut3-dev

                  I've install GLUT: sudo apt-get install freeglut3 freeglut3-dev

                  /usr/lib 中有:libglut.a
                  libglut.so
                  libglut.so.3
                  libglut.so.3.9.0

                  There are in /usr/lib: libglut.a
                  libglut.so
                  libglut.so.3
                  libglut.so.3.9.0

                  locate glu.h
                  /home/goran/QtSDK/QtSources/4.8.0/src/3rdparty/webkit/Source/ThirdParty/glu/internal_glu.h
                  /usr/include/GL/glu.h
                  
                  /usr/include/GL/gl.h
                  
                  locate gl.h
                  ...
                  /usr/include/GL/gl.h
                  

                  我做错了什么?

                  推荐答案

                  GCC 链接器可能会按照它们在命令行上的顺序扫描库,这意味着它可能会先扫描库,然后发现没有人使用它们,因此你会得到错误.可以肯定的是,将库放在命令行的最后:

                  The GCC linker may scan libraries in the order they are on the command line, which means for you it may scan the libraries first and sees no one using them, and therefore you get the errors. To be sure, place the libraries last on the command line:

                  gcc hw_opengl.cpp -o hw_opengl -lGL -lGLU -lglut
                  

                  这篇关于在 ubuntu 中编译 GLUT 时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:向心 Catmull-Rom 样条如何工作? 下一篇:glPushMatrix() 和 glPopMatrix() 如何保持场景相同?

                  相关文章

                  最新文章

                3. <tfoot id='IDKyc'></tfoot>

                  1. <small id='IDKyc'></small><noframes id='IDKyc'>

                    1. <i id='IDKyc'><tr id='IDKyc'><dt id='IDKyc'><q id='IDKyc'><span id='IDKyc'><b id='IDKyc'><form id='IDKyc'><ins id='IDKyc'></ins><ul id='IDKyc'></ul><sub id='IDKyc'></sub></form><legend id='IDKyc'></legend><bdo id='IDKyc'><pre id='IDKyc'><center id='IDKyc'></center></pre></bdo></b><th id='IDKyc'></th></span></q></dt></tr></i><div id='IDKyc'><tfoot id='IDKyc'></tfoot><dl id='IDKyc'><fieldset id='IDKyc'></fieldset></dl></div>

                      • <bdo id='IDKyc'></bdo><ul id='IDKyc'></ul>
                      <legend id='IDKyc'><style id='IDKyc'><dir id='IDKyc'><q id='IDKyc'></q></dir></style></legend>