Linux-Mint
無法編譯 OpenGL 程式碼
我在筆記型電腦上執行 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
我決定在Nvidia論壇上詢問並得到答案。我會在這裡留下一個完整的執行緒,以便任何人都可以理解它周圍的整個事情。