在Ubuntu 11.10中安装所有OpenGL库以进行开发

时间:2011-12-02 08:13:27

标签: c++ c opengl ubuntu glew

我刚刚安装了ubuntu 11.10。

我按照this问题中的第一个答案。我安装了: freeglut3 freeglut3-dev的

igor@ubuntu:~$ sudo apt-get install freeglut3
[sudo] password for igor: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  freeglut3
0 upgraded, 1 newly installed, 0 to remove and 253 not upgraded.
Need to get 77.5 kB of archives.
After this operation, 315 kB of additional disk space will be used.
Get:1 http://us.archive.ubuntu.com/ubuntu/ oneiric/main freeglut3 i386 2.6.0-1ubuntu2 [77.5 kB]
Fetched 77.5 kB in 0s (82.9 kB/s)    
Selecting previously deselected package freeglut3.
(Reading database ... 125550 files and directories currently installed.)
Unpacking freeglut3 (from .../freeglut3_2.6.0-1ubuntu2_i386.deb) ...
Setting up freeglut3 (2.6.0-1ubuntu2) ...
Processing triggers for libc-bin ...
ldconfig deferred processing now taking place
igor@ubuntu:~$ sudo apt-get install freeglut3-dev
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
  libdrm-dev libgl1-mesa-dev libglu1-mesa-dev libice-dev libkms1
  libpthread-stubs0 libpthread-stubs0-dev libsm-dev libx11-dev libxau-dev
  libxcb1-dev libxdmcp-dev libxext-dev libxt-dev mesa-common-dev
  x11proto-core-dev x11proto-input-dev x11proto-kb-dev x11proto-xext-dev
  xorg-sgml-doctools xtrans-dev
The following NEW packages will be installed:
  freeglut3-dev libdrm-dev libgl1-mesa-dev libglu1-mesa-dev libice-dev libkms1
  libpthread-stubs0 libpthread-stubs0-dev libsm-dev libx11-dev libxau-dev
  libxcb1-dev libxdmcp-dev libxext-dev libxt-dev mesa-common-dev
  x11proto-core-dev x11proto-input-dev x11proto-kb-dev x11proto-xext-dev
  xorg-sgml-doctools xtrans-dev
0 upgraded, 22 newly installed, 0 to remove and 253 not upgraded.
Need to get 5,673 kB of archives.
After this operation, 23.7 MB of additional disk space will be used.
Do you want to continue [Y/n]? Y
Get:1 http://us.archive.ubuntu.com/ubuntu/ oneiric/main libkms1 i386 2.4.26-1ubuntu1 [9,654 B]
Get:2 http://us.archive.ubuntu.com/ubuntu/ oneiric/main xorg-sgml-doctools i386 1:1.8-2 [10.9 kB]
Get:3 http://us.archive.ubuntu.com/ubuntu/ oneiric/main x11proto-core-dev i386 7.0.22-1 [299 kB]
Get:4 http://us.archive.ubuntu.com/ubuntu/ oneiric/main libxau-dev i386 1:1.0.6-3 [10.2 kB]
Get:5 http://us.archive.ubuntu.com/ubuntu/ oneiric/main libxdmcp-dev i386 1:1.1.0-3 [43.9 kB]
Get:6 http://us.archive.ubuntu.com/ubuntu/ oneiric/main x11proto-input-dev i386 2.0.2-2ubuntu1 [69.0 kB]
Get:7 http://us.archive.ubuntu.com/ubuntu/ oneiric/main x11proto-kb-dev i386 1.0.5-2 [27.6 kB]
Get:8 http://us.archive.ubuntu.com/ubuntu/ oneiric/main xtrans-dev i386 1.2.6-2 [82.9 kB]
Get:9 http://us.archive.ubuntu.com/ubuntu/ oneiric/main libpthread-stubs0 i386 0.3-2.1 [3,270 B]
Get:10 http://us.archive.ubuntu.com/ubuntu/ oneiric/main libpthread-stubs0-dev i386 0.3-2.1 [2,490 B]
Get:11 http://us.archive.ubuntu.com/ubuntu/ oneiric/main libxcb1-dev i386 1.7-3 [77.9 kB]
Get:12 http://us.archive.ubuntu.com/ubuntu/ oneiric/main libx11-dev i386 2:1.4.4-2ubuntu1 [3,252 kB]
Get:13 http://us.archive.ubuntu.com/ubuntu/ oneiric/main libdrm-dev i386 2.4.26-1ubuntu1 [123 kB]
Get:14 http://us.archive.ubuntu.com/ubuntu/ oneiric/main mesa-common-dev i386 7.11-0ubuntu3 [236 kB]
Get:15 http://us.archive.ubuntu.com/ubuntu/ oneiric/main x11proto-xext-dev i386 7.2.0-3 [253 kB]
Get:16 http://us.archive.ubuntu.com/ubuntu/ oneiric/main libxext-dev i386 2:1.3.0-3 [141 kB]
Get:17 http://us.archive.ubuntu.com/ubuntu/ oneiric/main libgl1-mesa-dev i386 7.11-0ubuntu3 [9,248 B]
Get:18 http://us.archive.ubuntu.com/ubuntu/ oneiric/main libglu1-mesa-dev i386 7.11-0ubuntu3 [189 kB]
Get:19 http://us.archive.ubuntu.com/ubuntu/ oneiric/main libice-dev i386 2:1.0.7-2 [128 kB]
Get:20 http://us.archive.ubuntu.com/ubuntu/ oneiric/main libsm-dev i386 2:1.2.0-2 [86.4 kB]
Get:21 http://us.archive.ubuntu.com/ubuntu/ oneiric/main libxt-dev i386 1:1.1.1-2 [472 kB]
Get:22 http://us.archive.ubuntu.com/ubuntu/ oneiric/main freeglut3-dev i386 2.6.0-1ubuntu2 [146 kB]
Fetched 5,673 kB in 16s (336 kB/s)                                             
Selecting previously deselected package libkms1.
(Reading database ... 125555 files and directories currently installed.)
Unpacking libkms1 (from .../libkms1_2.4.26-1ubuntu1_i386.deb) ...
Selecting previously deselected package xorg-sgml-doctools.
Unpacking xorg-sgml-doctools (from .../xorg-sgml-doctools_1%3a1.8-2_i386.deb) ...
Selecting previously deselected package x11proto-core-dev.
Unpacking x11proto-core-dev (from .../x11proto-core-dev_7.0.22-1_i386.deb) ...
Selecting previously deselected package libxau-dev.
Unpacking libxau-dev (from .../libxau-dev_1%3a1.0.6-3_i386.deb) ...
Selecting previously deselected package libxdmcp-dev.
Unpacking libxdmcp-dev (from .../libxdmcp-dev_1%3a1.1.0-3_i386.deb) ...
Selecting previously deselected package x11proto-input-dev.
Unpacking x11proto-input-dev (from .../x11proto-input-dev_2.0.2-2ubuntu1_i386.deb) ...
Selecting previously deselected package x11proto-kb-dev.
Unpacking x11proto-kb-dev (from .../x11proto-kb-dev_1.0.5-2_i386.deb) ...
Selecting previously deselected package xtrans-dev.
Unpacking xtrans-dev (from .../xtrans-dev_1.2.6-2_i386.deb) ...
Selecting previously deselected package libpthread-stubs0.
Unpacking libpthread-stubs0 (from .../libpthread-stubs0_0.3-2.1_i386.deb) ...
Selecting previously deselected package libpthread-stubs0-dev.
Unpacking libpthread-stubs0-dev (from .../libpthread-stubs0-dev_0.3-2.1_i386.deb) ...
Selecting previously deselected package libxcb1-dev.
Unpacking libxcb1-dev (from .../libxcb1-dev_1.7-3_i386.deb) ...
Selecting previously deselected package libx11-dev.
Unpacking libx11-dev (from .../libx11-dev_2%3a1.4.4-2ubuntu1_i386.deb) ...
Selecting previously deselected package libdrm-dev.
Unpacking libdrm-dev (from .../libdrm-dev_2.4.26-1ubuntu1_i386.deb) ...
Selecting previously deselected package mesa-common-dev.
Unpacking mesa-common-dev (from .../mesa-common-dev_7.11-0ubuntu3_i386.deb) ...
Selecting previously deselected package x11proto-xext-dev.
Unpacking x11proto-xext-dev (from .../x11proto-xext-dev_7.2.0-3_i386.deb) ...
Selecting previously deselected package libxext-dev.
Unpacking libxext-dev (from .../libxext-dev_2%3a1.3.0-3_i386.deb) ...
Selecting previously deselected package libgl1-mesa-dev.
Unpacking libgl1-mesa-dev (from .../libgl1-mesa-dev_7.11-0ubuntu3_i386.deb) ...
Selecting previously deselected package libglu1-mesa-dev.
Unpacking libglu1-mesa-dev (from .../libglu1-mesa-dev_7.11-0ubuntu3_i386.deb) ...
Selecting previously deselected package libice-dev.
Unpacking libice-dev (from .../libice-dev_2%3a1.0.7-2_i386.deb) ...
Selecting previously deselected package libsm-dev.
Unpacking libsm-dev (from .../libsm-dev_2%3a1.2.0-2_i386.deb) ...
Selecting previously deselected package libxt-dev.
Unpacking libxt-dev (from .../libxt-dev_1%3a1.1.1-2_i386.deb) ...
Selecting previously deselected package freeglut3-dev.
Unpacking freeglut3-dev (from .../freeglut3-dev_2.6.0-1ubuntu2_i386.deb) ...
Processing triggers for man-db ...
Setting up libkms1 (2.4.26-1ubuntu1) ...
Setting up xorg-sgml-doctools (1:1.8-2) ...
Setting up x11proto-core-dev (7.0.22-1) ...
Setting up libxau-dev (1:1.0.6-3) ...
Setting up libxdmcp-dev (1:1.1.0-3) ...
Setting up x11proto-input-dev (2.0.2-2ubuntu1) ...
Setting up x11proto-kb-dev (1.0.5-2) ...
Setting up xtrans-dev (1.2.6-2) ...
Setting up libpthread-stubs0 (0.3-2.1) ...
Setting up libpthread-stubs0-dev (0.3-2.1) ...
Setting up libxcb1-dev (1.7-3) ...
Setting up libx11-dev (2:1.4.4-2ubuntu1) ...
Setting up libdrm-dev (2.4.26-1ubuntu1) ...
Setting up mesa-common-dev (7.11-0ubuntu3) ...
Setting up x11proto-xext-dev (7.2.0-3) ...
Setting up libxext-dev (2:1.3.0-3) ...
Setting up libgl1-mesa-dev (7.11-0ubuntu3) ...
Setting up libglu1-mesa-dev (7.11-0ubuntu3) ...
Setting up libice-dev (2:1.0.7-2) ...
Setting up libsm-dev (2:1.2.0-2) ...
Setting up libxt-dev (1:1.1.1-2) ...
Setting up freeglut3-dev (2.6.0-1ubuntu2) ...
Processing triggers for libc-bin ...
ldconfig deferred processing now taking place

现在我尝试安装libglew1.5和libglew1.5-dev等。 但是:

$ sudo apt-get install libglew1.5
Reading package lists... Done
Building dependency tree       
Reading state information... Done
libglew1.5 is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 251 not upgraded.

我尝试从这个答案中编译示例:

#include < GL/glew.h >
#include < GL/glut.h >
#include < GL/gl.h >
#include < GL/glu.h >
#include < GL/glext.h >

GLenum err = glewInit();
if (GLEW_OK != err)
{
    fprintf(stderr, "Error %s\n", glewGetErrorString(err));
    exit(1);
}
fprintf(stdout, "Status: Using GLEW %s\n", glewGetString(GLEW_VERSION));

if (GLEW_ARB_vertex_program)
    fprintf(stdout, "Status: ARB vertex programs available.\n");

if (glewGetExtension("GL_ARB_fragment_program"))
    fprintf(stdout, "Status: ARB fragment programs available.\n");

if (glewIsSupported("GL_VERSION_1_4  GL_ARB_point_sprite"))
    fprintf(stdout, "Status: ARB point sprites available.\n");

并编译错误

$ g++ -lglut -lGL -lGLU -lGLEW example.cpp -o examp
example.cpp:1:23: fatal error:  GL/glew.h : No such file or directory
compilation terminated.

enter image description here

在哪里可以找到安装opengl libs用于开发的常规教程?对于OpenGL ES至关重要......

2 个答案:

答案 0 :(得分:12)

删除&lt;中的空格。 &GT;它会编译。因此,而不是写< GL/glew.h ><GL/glew.h>

答案 1 :(得分:4)

尝试以这种方式编译:

g++ -I/usr/include -L/usr/lib -lglut -lGL -lGLU -lGLEW example.cpp -o example

默认情况下,g ++更有可能在GL/glew.h中查找/usr/local/include,但无法找到它。