简体   繁体   English

Qt debian / ubuntu:无法编译,错误:找不到-lGL

[英]Qt debian/ubuntu: Can't compile, error: cannot find -lGL

I have a problem building applications in Qt on Debian. 我在Debian的Qt中构建应用程序时遇到问题。

When I try to compile anything I get: 当我尝试编译任何我得到的东西:

/usr/bin/ld: cannot find -lGL collect2: error: ld returned 1 exit status make: *** [test] Error 1 14:38:52: Proces "/usr/bin/make" zakończył się kodem wyjściowym 2.

Last line means: Procces(...) exited with code: 2 最后一行表示: Procces(...)退出,代码为: 2

Any idea what's wrong? 知道什么是错的吗?

Since this is a linker error, you may have one of two problems: 由于这是链接器错误,因此您可能遇到以下两个问题之一:

  • You don't have libGL installed 您没有安装libGL
  • libGL is installed but not in your system path. libGL已安装但不在您的系统路径中。

If libGL isn't installed, you can install it: 如果未安装libGL,则可以安装它:

sudo apt-get install libgl1-mesa-dev

I think is the right package. 我认为是正确的方案。 I don't have a debian machine handy so I can't test it. 我没有方便的debian机器所以我无法测试它。

If you have this package installed, you need to add it to your system path. 如果安装了此软件包,则需要将其添加到系统路径中。 You'll need to append it to environment variable LD_LIBRARY_PATH or make a .conf file located in /etc/ld.so.conf.d/ . 您需要将它附加到环境变量LD_LIBRARY_PATH或创建位于/etc/ld.so.conf.d/.conf文件。

Again, I don't have a debian machine to verify these paths, but that's the best I can do from memory. 同样,我没有debian机器来验证这些路径,但这是我能从记忆中做到的最好的。 Either way, this should be enough information to get started. 无论哪种方式,这应该是足够的信息来开始。

Good luck! 祝好运!

You need to install the relevant packages into your path to be able to link against it. 您需要将相关的软件包安装到您的路径中才能链接到它。 Having only the headers right is not enough because that will only get you through the compilation, but not the linkage stage. 只有正确的标题是不够的,因为这只会让你完成编译,而不是链接阶段。

Just use your package manager because it will put you all this into the right path by default: 只需使用您的包管理器,因为它会默认将所有这些放入正确的路径:

sudo apt-get install libgl1-mesa-dev

Also, note that in general if you had not had the headers installed either, just get rid of the dependency in your application because it means you do not really depend on the library, just formally. 此外,请注意,一般情况下,如果您还没有安装标头,只需删除应用程序中的依赖项,因为这意味着您并不是真正依赖于库,只是正式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM