GCC/usr/bin/ld:找不到-lGl [英] GCC /usr/bin/ld: cannot find -lGl

查看:309
本文介绍了GCC/usr/bin/ld:找不到-lGl的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

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

这将导致:

 /usr/bin/ld:找不到-lGlcollect2:错误:ld返回1退出状态Makefile:16:目标全部"的配方失败制作:*** [全部]错误1 

我在:

  Ubuntu 16.04 LTS 

海湾合作委员会:

  gcc版本5.3.1 20160413(Ubuntu 5.3.1-14ubuntu2) 

libGL.so

 <代码>/usr/lib/x86_64-linux-gnu $查找libGL.solibGL.so 

我已安装:

  freeglut3 freeglut3-dev libglew1.5 libglew1.5-dev libglu1-mesa libglu1-mesa-dev libgl1-mesa-glx libgl1-mesa-dev 

我错过了什么吗?上一次我成功编译时,我使用的是Ubuntu 14.04.

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

更新:

  glxinfoOpenGL供应商字符串:英特尔开放源技术中心OpenGL渲染器字符串:Mesa DRI Intel(R)HD Graphics 5500(Broadwell GT2)OpenGL核心配置文件版本字符串:3.3(核心配置文件)Mesa 11.2.0OpenGL核心配置文件着色语言版本字符串:3.30OpenGL核心配置文件上下文标志:(无)OpenGL核心配置文件配置文件掩码:核心配置文件OpenGL核心配置文件扩展名:OpenGL版本字符串:3.0 Mesa 11.2.0OpenGL着色语言版本字符串:1.30OpenGL上下文标志:(无)OpenGL扩展:OpenGL ES配置文件版本字符串:OpenGL ES 3.1 Mesa 11.2.0OpenGL ES配置文件底纹语言版本字符串:OpenGL ES GLSL ES 3.10OpenGL ES配置文件扩展名: 

我的ldconfig.real似乎为空

解决方案

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

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

UNIX文件名区分大小写.

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

知道错了.它应该是 -lGL ,并且/usr/lib/x86_64-linux-gnu 中存在 libGL.so ,没有 no方式,您将得到相同的错误(可能是与 ld 的错误不同(重要),而来自 make 的错误(无关紧要))).

更新:

/usr/bin/ld:找不到-lGL

好的.必须/usr/lib/x86_64-linux-gnu/libGL.so 是悬挂的符号链接,或指向32位库,或者已损坏以其他方式.

更新2:

 /usr/lib/x86_64-linux-gnu/libGL.so:断开到/usr/lib/libGL.so.1.2的符号链接2 

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

  sudo apt-get install --reinstall libgl1-mesa-dev 

eI'm trying to compile a c++ openGL program using libGL and freeglut3. Im trying:

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

or

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

Which results in:

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

I'm on:

Ubuntu 16.04 LTS

GCC:

gcc version 5.3.1 20160413 (Ubuntu 5.3.1-14ubuntu2)

libGL.so

/usr/lib/x86_64-linux-gnu$ find libGL.so
libGL.so

I installed:

freeglut3 freeglut3-dev libglew1.5 libglew1.5-dev libglu1-mesa libglu1-mesa-dev libgl1-mesa-glx libgl1-mesa-dev

Am I missing anything? Last time I successfully compiled I was on ubuntu 14.04.

I read somewhere that I should install fglrx-glx but the package is not available.

Update:

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:

My ldconfig.real appears to be empty

解决方案

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

This command is incorrect: you want to link against libGL, not libGl, so the command should be: g++ main.cpp -w -lglut -lGL -o bin/app

UNIX file names are case-sensitive.

I know its Gl for sure, but I tried -lGL and it gave the same error

You know wrong. It should be -lGL, and with libGL.so present in /usr/lib/x86_64-linux-gnu there is no way you are getting the same error (possibly you get a different error from ld (which matters) but the same error from make (which doesn't matter)).

Update:

/usr/bin/ld: cannot find -lGL

Ok. It must be that /usr/lib/x86_64-linux-gnu/libGL.so is either a dangling symlink, or points to a 32-bit library, or is corrupt in some other way.

Update 2:

 /usr/lib/x86_64-linux-gnu/libGL.so: broken symbolic link to /usr/lib/libGL.so.1.2 2

Indeed it's a broken symlink. To fix this, reinstall the package which provides it:

sudo apt-get install --reinstall libgl1-mesa-dev

这篇关于GCC/usr/bin/ld:找不到-lGl的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆