4

I have installed qt and when I run application on qt I get this error.

 /usr/bin/ld: cannot find -lGL
 collect2: error: ld returned 1 exit status
 make: *** [test3] Error 1
 14:05:48: The process "/usr/bin/make" exited with code 2.

I think this error is related to OpenGL.
I have run all these commands but nothing happened

 sudo apt-get install libgl1-mesa-dev
 sudo apt-get install libgl1-mesa-glx libgl1-mesa-dev

My pro file is :

  #-------------------------------------------------
  #
  # Project created by QtCreator 2015-05-19T17:40:19
  #
  #-------------------------------------------------

  QT       += core gui

   greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

  TARGET = test19
  TEMPLATE = app

   SOURCES += main.cpp\
    mainwindow.cpp

   HEADERS  += mainwindow.h

   FORMS    += mainwindow.ui
genpfault
  • 51,148
  • 11
  • 85
  • 139
Amina Yousuf
  • 115
  • 3
  • 8
  • Run `ldconfig -p | grep libGL.so`. If it contains `libGL.so` - restart QtCreator. – Amartel May 19 '15 at 09:44
  • Are you following http://wiki.qt.io/Building-Qt-5-from-Git? That usually gets the job done for me when I'm setting up a Linux machine. – Mitch May 19 '15 at 09:45
  • terminal shows me this when i run command libGL.so.1 (libc6,x86-64, OS ABI: Linux 2.4.20) => /usr/lib/x86_64-linux-gnu/mesa/libGL.so.1 libGL.so.1 (libc6, OS ABI: Linux 2.4.20) => /usr/lib/i386-linux-gnu/mesa/libGL.so.1 I have closed qt creator and then run it again but got the same error @Amartel – Amina Yousuf May 19 '15 at 09:49

1 Answers1

1

terminal shows me this when i run command

libGL.so.1 (libc6,x86-64, OS ABI: Linux 2.4.20) => /usr/lib/x86_64-linux-gnu/mesa/libGL.so.1 libGL.so.1 (libc6, OS ABI: Linux 2.4.20) => /usr/lib/i386-linux-gnu/mesa/libGL.so.1

Proper links where not created while installing needed packages. I don't know why, but here is how you can fix this:

sudo ln -s /usr/lib/x86_64-linux-gnu/mesa/libGL.so.1 /usr/lib/x86_64-linux-gnu/mesa/libGL.so
sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/mesa/libGL.so
sudo ldconfig
Community
  • 1
  • 1
Amartel
  • 4,248
  • 2
  • 15
  • 21
  • Does `ldconfig -p | grep libGL.so` shows all 4 libs now? – Amartel May 19 '15 at 10:05
  • libGL.so.1 (libc6,x86-64, OS ABI: Linux 2.4.20) => /usr/lib/x86_64-linux-gnu/mesa/libGL.so.1 libGL.so.1 (libc6, OS ABI: Linux 2.4.20) => /usr/lib/i386-linux-gnu/mesa/libGL.so.1 libGL.so (libc6,x86-64, OS ABI: Linux 2.4.20) => /usr/lib/x86_64-linux-gnu/mesa/libGL.so libGL.so (libc6, OS ABI: Linux 2.4.20) => /usr/lib/i386-linux-gnu/mesa/libGL.so yup @ Amartel – Amina Yousuf May 19 '15 at 10:07
  • Restart (just in case), open a terminal and run these commands: `cd /tmp`, `echo "int main() {return 0;}" > main.cpp`, `gcc -lGL -omain main.cpp`. If it finishes without errors, then your linker is fine - try to rebuild your project (`Build->Rebuild All`). – Amartel May 19 '15 at 10:18
  • Same error on my example, or on rebuilding project? – Amartel May 19 '15 at 11:20
  • Could you add your 'pro' file to your question. – Amartel May 19 '15 at 11:35
  • I have updated my question by adding pro file @Amartel – Amina Yousuf May 19 '15 at 12:45
  • Try one of these: http://stackoverflow.com/questions/18558406/usr-bin-ld-cannot-find-lgl-when-building-a-qt-application or http://stackoverflow.com/questions/11867913/ubuntu-12-04-usr-bin-ld-error-cannot-find-lgl – Amartel May 20 '15 at 06:34