我在笔记本电脑上运行 Linux Mint 19.1 并面临这个问题。当我尝试使用 OpenGL 库编译 C++ 程序时,它说:
$ make
g++ solsys.cpp -lglut -lGLEW -lGL -lGLU -fpermissive -o solsys
/usr/bin/ld: cannot find -lGL
collect2: error: ld returned 1 exit status
<builtin>: recipe for target 'solsys' failed
make: *** [solsys] Error 1
当我之前尝试运行已经编译的程序时,但在这台机器上它说
./rotation: error while loading shared libraries: libGLEW.so.1.13: cannot open shared object file: No such file or directory
我实际上理解问题在于库安装不正确,但无法解决。
glxino | grep OpenGL
输出这个
OpenGL vendor string: Intel Open Source Technology Center
OpenGL renderer string: Mesa DRI Intel(R) Haswell Mobile
OpenGL core profile version string: 4.5 (Core Profile) Mesa 18.0.5
OpenGL core profile shading language version string: 4.50
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile
OpenGL core profile extensions:
OpenGL version string: 3.0 Mesa 18.0.5
OpenGL shading language version string: 1.30
OpenGL context flags: (none)
OpenGL extensions:
OpenGL ES profile version string: OpenGL ES 3.1 Mesa 18.0.5
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.10
OpenGL ES profile extensions:
顺便说一句,我在笔记本电脑上安装 Nvidia 驱动程序时遇到了问题,但后来放弃了。
$lspci | grep "NVIDIA"
04:00.0 3D controller: NVIDIA Corporation GF117M [GeForce 610M/710M/810M/820M / GT 620M/625M/630M/720M] (rev a1)
更新:
$ sudo apt-get install libglew-dev libgl1-mesa-dev libglu1-mesa-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
libglu1-mesa-dev is already the newest version (9.0.0-2.1build1).
libglu1-mesa-dev set to manually installed.
libglew-dev is already the newest version (2.0.0-5).
libgl1-mesa-dev is already the newest version (18.0.5-0ubuntu0~18.04.1).
0 upgraded, 0 newly installed, 0 to remove and 36 not upgraded.
...
$ dpkg -l | grep mesa
ii libegl-mesa0:amd64 18.0.5-0ubuntu0~18.04.1 amd64 free implementation of the EGL API -- Mesa vendor library
ii libegl1-mesa:amd64 18.0.5-0ubuntu0~18.04.1 amd64 transitional dummy package
ii libegl1-mesa-dev:amd64 18.0.5-0ubuntu0~18.04.1 amd64 free implementation of the EGL API -- development files
ii libgl1-mesa-dev:amd64 18.0.5-0ubuntu0~18.04.1 amd64 free implementation of the OpenGL API -- GLX development files
ii libgl1-mesa-dri:amd64 18.0.5-0ubuntu0~18.04.1 amd64 free implementation of the OpenGL API -- DRI modules
ii libgl1-mesa-dri:i386 18.0.5-0ubuntu0~18.04.1 i386 free implementation of the OpenGL API -- DRI modules
ii libgl1-mesa-glx:amd64 18.0.5-0ubuntu0~18.04.1 amd64 transitional dummy package
ii libgl1-mesa-glx:i386 18.0.5-0ubuntu0~18.04.1 i386 transitional dummy package
ii libglapi-mesa:amd64 18.0.5-0ubuntu0~18.04.1 amd64 free implementation of the GL API -- shared library
ii libglapi-mesa:i386 18.0.5-0ubuntu0~18.04.1 i386 free implementation of the GL API -- shared library
ii libgles2-mesa:amd64 18.0.5-0ubuntu0~18.04.1 amd64 transitional dummy package
ii libgles2-mesa-dev:amd64 18.0.5-0ubuntu0~18.04.1 amd64 free implementation of the OpenGL|ES 2.x API -- development files
ii libglu1-mesa:amd64 9.0.0-2.1build1 amd64 Mesa OpenGL utility library (GLU)
ii libglu1-mesa:i386 9.0.0-2.1build1 i386 Mesa OpenGL utility library (GLU)
ii libglu1-mesa-dev:amd64 9.0.0-2.1build1 amd64 Mesa OpenGL utility library -- development files
ii libglx-mesa0:amd64 18.0.5-0ubuntu0~18.04.1 amd64 free implementation of the OpenGL API -- GLX vendor library
ii libglx-mesa0:i386 18.0.5-0ubuntu0~18.04.1 i386 free implementation of the OpenGL API -- GLX vendor library
ii libosmesa6:amd64 18.0.5-0ubuntu0~18.04.1 amd64 Mesa Off-screen rendering extension
ii libosmesa6:i386 18.0.5-0ubuntu0~18.04.1 i386 Mesa Off-screen rendering extension
ii libwayland-egl1-mesa:amd64 18.0.5-0ubuntu0~18.04.1 amd64 implementation of the Wayland EGL platform -- runtime
ii mesa-common-dev:amd64 18.0.5-0ubuntu0~18.04.1 amd64 Developer documentation for Mesa
ii mesa-utils 8.4.0-1 amd64 Miscellaneous Mesa GL utilities
连锁:
$ ls -l /usr/lib/x86_64-linux-gnu/libGL.so*
lrwxrwxrwx 1 root root 14 Jan 16 19:09 /usr/lib/x86_64-linux-gnu/libGL.so.1 -> libGL.so.1.0.0
-rw-r--r-- 1 root root 567624 Aug 15 12:20 /usr/lib/x86_64-linux-gnu/libGL.so.1.0.0