在linux上安装Qt,找不到-lGL
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15355837/
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
Installing Qt on linux, cannot find -lGL
提问by Gradient
I'm having a hard time trying to install Qt on linux. I downloaded the .run file on the website and installed Qt. However, when I try to compile the default Hello World project using Qtcreator, I get the following :
我很难在 linux 上安装 Qt。我在网站上下载了 .run 文件并安装了 Qt。但是,当我尝试使用 Qtcreator 编译默认的 Hello World 项目时,我得到以下信息:
error cannot find -lGL
I was able to solve the problem by issuing the command :
我能够通过发出命令来解决问题:
sudo apt-get install libqt4-dev
But, I'm not satisfied with the solution as I want to use Qt5 and the name of the lib I downloaded implies version 4. Can someone explain what is going on and tell me if my solution is correct? If not, what should I do to get a working Qt on Linux.
但是,我对解决方案不满意,因为我想使用 Qt5 并且我下载的库的名称暗示了版本 4。有人可以解释发生了什么并告诉我我的解决方案是否正确?如果没有,我应该怎么做才能在 Linux 上运行 Qt。
Additional question
补充问题
The correct answer, as provided by LtWorf, was to install libgl-dev. For future problems of this sort, can someone tell me how I should have guessed that I had to download this particular library? And why are there some libs with -devat the end? What do they provide?
LtWorf提供的正确答案是安装libgl-dev。对于此类未来的问题,有人能告诉我我应该怎么猜到我必须下载这个特定的库吗?为什么最后有一些带有-dev 的库?他们提供什么?
采纳答案by LtWorf
Well it is trying to link with libgl and doesn't find it. You should install libgl-dev.
好吧,它正在尝试与 libgl 链接但没有找到它。您应该安装libgl-dev。
-l
is a linker option, it tells the linker to use a certain library.
For example you can have -lmagic
meaning that you want to use libmagic.
-l
是一个链接器选项,它告诉链接器使用某个库。例如,您可以-lmagic
表示要使用libmagic。
Normally all libraries are called libsomething, and on debian you will find 3 packages called: libsomething libsomething-dbg libsomething-dev
通常所有的库都被称为 libsomething,在 debian 上你会发现 3 个包: libsomething libsomething-dbg libsomething-dev
The 1st one is the library, the second one is the library compiled with the debug symbols, so you can make sense of stacktraces more easily, and the final one is the development package, it contains the .h files so you can link to the library.
第一个是库,第二个是使用调试符号编译的库,因此您可以更轻松地理解堆栈跟踪,最后一个是开发包,它包含 .h 文件,因此您可以链接到图书馆。
回答by Zlatomir
Do you have libgl-devinstalled? If not install it and it should work.
你有安装libgl-dev吗?如果没有安装它,它应该可以工作。
回答by lourencoccc
On Fedora 17, I did:
在 Fedora 17 上,我做了:
sudo yum install mesa-libGL-devel
回答by Triangle
sudo apt-get install libgl-dev
sudo apt-get install libgl-dev
回答by JimmyJimJames
Those other posters are correct, but on some systems, the lib to install is named differently. I just dealt with a 32bit Ubuntu 14.04.5 LTS system, and libgl-devwas not available.
那些其他海报是正确的,但在某些系统上,要安装的库的名称不同。我刚刚处理了一个 32 位 Ubuntu 14.04.5 LTS 系统,并且libgl-dev不可用。
Instead, I needed to install the libgl1-mesa-devpackage via:
相反,我需要通过以下方式安装libgl1-mesa-dev包:
sudo apt-get install libgl1-mesa-dev