GCC /usr/bin/ld:找不到-lGl

Nic*_*ick -2 c++ opengl ubuntu linker gcc

e我正在尝试使用 libGL 和 freeglut3 编译 c++ openGL 程序。我想:

g++ main.cpp -w -lglut -lGl -o bin/app
Run Code Online (Sandbox Code Playgroud)

或者

g++ main.cpp -w -lglut -lGL -o bin/app
Run Code Online (Sandbox Code Playgroud)

结果是:

/usr/bin/ld: cannot find -lGl
collect2: error: ld returned 1 exit status
Makefile:16: recipe for target 'all' failed
make: *** [all] Error 1
Run Code Online (Sandbox Code Playgroud)

我上线了:

Ubuntu 16.04 LTS
Run Code Online (Sandbox Code Playgroud)

海湾合作委员会:

gcc version 5.3.1 20160413 (Ubuntu 5.3.1-14ubuntu2)
Run Code Online (Sandbox Code Playgroud)

libGL库

/usr/lib/x86_64-linux-gnu$ find libGL.so
libGL.so
Run Code Online (Sandbox Code Playgroud)

我安装了:

freeglut3 freeglut3-dev libglew1.5 libglew1.5-dev libglu1-mesa libglu1-mesa-dev libgl1-mesa-glx libgl1-mesa-dev
Run Code Online (Sandbox Code Playgroud)

我错过了什么吗?上次我成功编译时是在 ubuntu 14.04 上。

我在某处读到我应该安装 fglrx-glx 但该软件包不可用。

更新:

glxinfo
OpenGL vendor string: Intel Open Source Technology Center
OpenGL renderer string: Mesa DRI Intel(R) HD Graphics 5500 (Broadwell GT2) 
OpenGL core profile version string: 3.3 (Core Profile) Mesa 11.2.0
OpenGL core profile shading language version string: 3.30
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile
OpenGL core profile extensions:
OpenGL version string: 3.0 Mesa 11.2.0
OpenGL shading language version string: 1.30
OpenGL context flags: (none)
OpenGL extensions:
OpenGL ES profile version string: OpenGL ES 3.1 Mesa 11.2.0
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.10
OpenGL ES profile extensions:
Run Code Online (Sandbox Code Playgroud)

我的 ldconfig.real 似乎是空的

Emp*_*ian 5

g++ main.cpp -w -lglut -lGl -o bin/app

此命令不正确:您想要链接到libGL,而不是libGl,因此命令应该是:g++ main.cpp -w -lglut -lGL -o bin/app

UNIX 文件名区分大小写。

我肯定知道它的 Gl,但我尝试了 -lGL 并且它给出了相同的错误

知道错了。它应该是-lGL,并且libGL.so存在 in ,/usr/lib/x86_64-linux-gnu不可能得到相同的错误(可能您会从ld(这很重要)得到不同的错误,但从make(这并不重要)得到相同的错误)。

更新:

/usr/bin/ld: cannot find -lGL

好的。它一定/usr/lib/x86_64-linux-gnu/libGL.so悬空符号链接,或者指向 32 位库,或者以其他方式损坏。

更新2:

 /usr/lib/x86_64-linux-gnu/libGL.so: broken symbolic link to /usr/lib/libGL.so.1.2 2
Run Code Online (Sandbox Code Playgroud)

事实上,这是一个损坏的符号链接。要解决此问题,请重新安装提供它的软件包:

sudo apt-get install --reinstall libgl1-mesa-dev
Run Code Online (Sandbox Code Playgroud)