C++ Qt:找不到 -lGL 错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18406369/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Qt: can't find -lGL error
提问by Hofmn
I just reinstalled QtCreator, created new project (Qt Application) an got this after compilation:
我刚刚重新安装了 QtCreator,创建了新项目(Qt Application)并在编译后得到了这个:
/usr/bin/ld: **cannot find -lGL**
collect2: error: ld returned 1 exit status
make: *** [untitled1] Error 1
18:07:41: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project untitled1 (kit: Desktop Qt 5.1.0 GCC 32bit)
When executing step 'Make'
(Project is empty, I did'n commit any changes)
(项目为空,我没有提交任何更改)
Qt Creator 2.7.2
Based on Qt 5.1.0 (32 bit)
Ubuntu 13.04
Qt Creator 2.7.2
基于 Qt 5.1.0(32 位)
Ubuntu 13.04
How do I solve this problem?
我该如何解决这个问题?
回答by Sayyed Hassan Amiri
You should install package "libgl1-mesa-dev":
你应该安装包“libgl1-mesa-dev”:
sudo apt install libgl1-mesa-dev
回答by destan
you don't need to install anything. libGL
is already installed with Ubuntu, you just need to soft link it. (tested for ubuntu 14.x and 15.x, might work for later versions)
你不需要安装任何东西。libGL
已经安装了 Ubuntu,你只需要软链接它。(针对 ubuntu 14.x 和 15.x 测试,可能适用于更高版本)
- First locate the GL library
- Then link it under /usr/lib
- If the library is missing, it can be installed via libgl1-mesa-dev package
- 首先定位GL库
- 然后在/usr/lib下链接
- 如果库缺失,可以通过 libgl1-mesa-dev 包安装
Here is how you could do this:
以下是您可以这样做的方法:
$ locate libGL
/usr/lib/i386-linux-gnu/mesa/libGL.so.1
/usr/lib/i386-linux-gnu/mesa/libGL.so.1.2.0
/usr/lib/x86_64-linux-gnu/libGLEW.so.1.10
/usr/lib/x86_64-linux-gnu/libGLEW.so.1.10.0
/usr/lib/x86_64-linux-gnu/libGLEWmx.so.1.10
/usr/lib/x86_64-linux-gnu/libGLEWmx.so.1.10.0
/usr/lib/x86_64-linux-gnu/libGLU.so.1
/usr/lib/x86_64-linux-gnu/libGLU.so.1.3.1
/usr/lib/x86_64-linux-gnu/mesa/libGL.so.1
/usr/lib/x86_64-linux-gnu/mesa/libGL.so.1.2.0
/usr/lib/x86_64-linux-gnu/mesa-egl/libGLESv2.so.2
/usr/lib/x86_64-linux-gnu/mesa-egl/libGLESv2.so.2.0.0
$ sudo ln -s /usr/lib/x86_64-linux-gnu/mesa/libGL.so.1 /usr/lib/libGL.so
回答by squeevee
The gui Qt module is included by default. If you don't want to use it in a project (e.g., it is a library or only uses stdio), you need to specify that in the .pro file.
默认情况下包含gui Qt 模块。如果您不想在项目中使用它(例如,它是一个库或仅使用 stdio),则需要在 .pro 文件中指定它。
QT -= gui
And the linker won't attempt to find lGL regardless of whether it is installed.
无论是否安装,链接器都不会尝试查找 lGL。
My case is admittedly a bit odd, since the main reason to use Qt is to create gui's. Installing the GL library is certainly not difficult, I just wanted to know why my quick and dirty Hello World wanted it.
诚然,我的情况有点奇怪,因为使用 Qt 的主要原因是创建 gui。安装 GL 库当然不难,我只是想知道为什么我的快速而肮脏的 Hello World 想要它。
回答by Sebastian Karlsson
This worked for me:
这对我有用:
sudo ln -s /usr/lib/libEGL1.so /usr/lib/libGL.so
回答by Shojib Mahmud
write:
写:
yum provides */libGL.so
after providing:
提供后:
yum install mesa-libGL-devel mesa-libGLU-devel
回答by Lastea
My system is Ubuntu 16.04 on x86 computer(with NVIDIA GeForce GPU).
我的系统是 x86 计算机上的 Ubuntu 16.04(带有 NVIDIA GeForce GPU)。
Check the library files located in /usr/lib/x86_64-linux-gnu
检查位于 /usr/lib/x86_64-linux-gnu
ls -al /usr/lib/x86_64-linux-gnu/libG*
If you see the broken link, reinstall libgl1-mesa-glx
如果您看到损坏的链接,请重新安装 libgl1-mesa-glx
sudo apt install --reinstall libgl1-mesa-glx
And, recheck library.
并且,重新检查库。
回答by nobjta_9x_tq
In my case: I have installed QT 32 bit lib in Win10 64 bit and it ran into error, I change to all 64 bit and QT creator run smoothly.
就我而言:我在 Win10 64 位中安装了 QT 32 位库,但遇到了错误,我更改为所有 64 位并且 QT 创建者运行顺利。
回答by Anonymous Suomynona
Solved this problem just a minute ago in suse. Just do the following step below and QTCreator should works just fine.
一分钟前在 suse 中解决了这个问题。只需执行以下步骤,QTCreator 应该可以正常工作。
sudo zypper install --type pattern devel_basis
sudo zypper install --type 模式 devel_basis