Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 527
Michał Zubrzycki Avatar asked Jan 13 '14 13:01

Michał Zubrzycki


2 Answers

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!

like image 84
Tyler Jandreau Avatar answered Nov 15 '22 11:11

Tyler Jandreau


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.

like image 1
lpapp Avatar answered Nov 15 '22 11:11

lpapp