求助: freebsd6.2 搭建 openGL 开发环境

发布于 2022-08-07 15:41:06 字数 4226 浏览 24 评论 1

如题.

#cd /usr/ports/graphics/freeglut/
#make install clean
#cd /usr/ports/graphics/libglut/
#make install clean

分别去找了这两个源.
http://heanet.dl.sourceforge.net/sourceforge/freeglut/freeglut-2.4.0.tar.gz
http://heanet.dl.sourceforge.net/sourceforge/mesa3d/MesaDemos-6.4.2.tar.gz

  1. #ls /usr/local/include/GL/
  2. freeglut.h      freeglut_ext.h  freeglut_std.h  glut.h

复制代码
//库文件有了。

  1. # gcc -lglut t.c -o t
  2. t.c:1:21: GL/glut.h: No such file or directory
  3. t.c: In function `display':
  4. t.c:5: error: `GL_COLOR_BUFFER_BIT' undeclared (first use in this function)
  5. t.c:5: error: (Each undeclared identifier is reported only once
  6. t.c:5: error: for each function it appears in.)
  7. t.c:10: error: `GL_POLYGON' undeclared (first use in this function)
  8. t.c: In function `init':
  9. t.c:26: error: `GL_PROJECTION' undeclared (first use in this function)
  10. t.c: In function `main':
  11. t.c:40: error: `GLUT_SINGLE' undeclared (first use in this function)
  12. t.c:40: error: `GLUT_RGB' undeclared (first use in this function)

复制代码
编译出错

t.c 找的一段测试代码:

  1. #include <GL/glut.h>
  2. void display(void)
  3. {
  4. /* clear all pixels  */
  5.         glClear (GL_COLOR_BUFFER_BIT);
  6. /* draw white polygon (rectangle) with corners at
  7. * (0.25, 0.25, 0.0) and (0.75, 0.75, 0.0)  
  8. */
  9.         glColor3f (1.0, 1.0, 1.0);
  10.         glBegin(GL_POLYGON);
  11.         glVertex3f (0.25, 0.25, 0.0);
  12.         glVertex3f (0.75, 0.25, 0.0);
  13.         glVertex3f (0.75, 0.75, 0.0);
  14.         glVertex3f (0.25, 0.75, 0.0);
  15.         glEnd();
  16. /* don't wait!  
  17. * start processing buffered OpenGL routines
  18. */
  19.         glFlush ();
  20. }
  21. void init (void)
  22. {
  23. /* select clearing color     */
  24.         glClearColor (0.0, 0.0, 0.0, 0.0);
  25. /* initialize viewing values  */
  26.         glMatrixMode(GL_PROJECTION);
  27.         glLoadIdentity();
  28.         glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
  29. }
  30. /*
  31. * Declare initial window size, position, and display mode
  32. * (single buffer and RGBA).  Open window with "hello"
  33. * in its title bar.  Call initialization routines.
  34. * Register callback function to display graphics.
  35. * Enter main loop and process events.
  36. */
  37. int main(int argc, char** argv)
  38. {
  39.         glutInit(&argc, argv);
  40.         glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
  41.         glutInitWindowSize (250, 250);
  42.         glutInitWindowPosition (100, 100);
  43.         glutCreateWindow ("hello");
  44.         init ();
  45.         glutDisplayFunc(display);
  46.         glutMainLoop();
  47.         return 0;   /* ANSI C requires main to return int. */
  48. }

复制代码

这个是什么原因呢??

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

飘落散花 2022-08-12 02:54:52

ln -s /usr/local/lib/libglut.so /usr/lib/libglut.so
ln -s /usr/local/include/GL    /usr/include/GL
后,错误如下

  1. #gcc -lglut t.c  -o t
  2. In file included from /usr/include/GL/glut.h:17,
  3.                  from t.c:1:
  4. /usr/include/GL/freeglut_std.h:114:19: GL/gl.h: No such file or directory
  5. /usr/include/GL/freeglut_std.h:115:20: GL/glu.h: No such file or directory
  6. In file included from /usr/include/GL/glut.h:17,
  7.                  from t.c:1:
  8. /usr/include/GL/freeglut_std.h:432: error: syntax error before "layer"
  9. /usr/include/GL/freeglut_std.h:491: error: syntax error before "query"
  10. /usr/include/GL/freeglut_std.h:492: error: syntax error before "query"
  11. /usr/include/GL/freeglut_std.h:494: error: syntax error before "query"
  12. /usr/include/GL/freeglut_std.h:509: error: syntax error before "size"
  13. /usr/include/GL/freeglut_std.h:510: error: syntax error before "size"
  14. /usr/include/GL/freeglut_std.h:511: error: syntax error before "radius"
  15. /usr/include/GL/freeglut_std.h:512: error: syntax error before "radius"
  16. /usr/include/GL/freeglut_std.h:513: error: syntax error before "base"
  17. /usr/include/GL/freeglut_std.h:514: error: syntax error before "base"
  18. /usr/include/GL/freeglut_std.h:516: error: syntax error before "innerRadius"
  19. /usr/include/GL/freeglut_std.h:517: error: syntax error before "innerRadius"
  20. /usr/include/GL/freeglut_std.h:530: error: syntax error before "size"
  21. /usr/include/GL/freeglut_std.h:531: error: syntax error before "size"
  22. /usr/include/GL/freeglut_std.h:539: error: syntax error before "query"
  23. /usr/include/GL/freeglut_std.h:544: error: syntax error before "query"
  24. /usr/include/GL/freeglut_std.h:553: error: syntax error before "GLfloat"
  25. /usr/include/GL/freeglut_std.h:554: error: syntax error before "glutGetColor"
  26. t.c: In function `display':
  27. t.c:5: error: `GL_COLOR_BUFFER_BIT' undeclared (first use in this function)
  28. t.c:5: error: (Each undeclared identifier is reported only once
  29. t.c:5: error: for each function it appears in.)
  30. t.c:10: error: `GL_POLYGON' undeclared (first use in this function)
  31. t.c: In function `init':
  32. t.c:26: error: `GL_PROJECTION' undeclared (first use in this function)

复制代码

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文