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

大兔子大兔子 提交于 2019-11-30 09:20:12

问题


I have a problem building applications in Qt on Debian.

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

Any idea what's wrong?


回答1:


Since this is a linker error, you may have one of two problems:

  • You don't have libGL installed
  • libGL is installed but not in your system path.

If libGL isn't installed, you can install it:

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.

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/.

Again, I don't have a debian machine to verify these paths, but that's the best I can do from memory. Either way, this should be enough information to get started.

Good luck!




回答2:


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.



来源:https://stackoverflow.com/questions/21092733/qt-debian-ubuntu-cant-compile-error-cannot-find-lgl

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!