PDA

View Full Version : Error: /usr/bin/ld: cannot find -lGL



tomkonikkara
25th December 2012, 06:43
I installed latest Qt 5 for Linux and tried to test by simply dragging and dropping a pushbutton and build. But it throws an error. I didn't get any idea. Here's the compile output:


11:54:57: Running steps for project Test...
11:54:57: Starting: "/usr/bin/make" clean -w
make: Entering directory `/home/tom/Data/Qt5/Test-build-Desktop_Qt_5_0_0_GCC_32bit_SDK-Debug'
rm -f moc_widget.cpp
rm -f ui_widget.h
rm -f main.o widget.o moc_widget.o
rm -f *~ core *.core
make: Leaving directory `/home/tom/Data/Qt5/Test-build-Desktop_Qt_5_0_0_GCC_32bit_SDK-Debug'
11:54:57: The process "/usr/bin/make" exited normally.
11:54:57: Configuration unchanged, skipping qmake step.
11:54:57: Starting: "/usr/bin/make" -w
make: Entering directory `/home/tom/Data/Qt5/Test-build-Desktop_Qt_5_0_0_GCC_32bit_SDK-Debug'
/home/tom/Programs/Qt/5.0.0/gcc/bin/uic ../Test/widget.ui -o ui_widget.h
g++ -c -pipe -g -Wall -W -D_REENTRANT -fPIE -DQT_QML_DEBUG -DQT_DECLARATIVE_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../../../Programs/Qt/5.0.0/gcc/mkspecs/linux-g++ -I../Test -I../../../Programs/Qt/5.0.0/gcc/include -I../../../Programs/Qt/5.0.0/gcc/include/QtWidgets -I../../../Programs/Qt/5.0.0/gcc/include/QtGui -I../../../Programs/Qt/5.0.0/gcc/include/QtCore -I. -I. -I. -o main.o ../Test/main.cpp
g++ -c -pipe -g -Wall -W -D_REENTRANT -fPIE -DQT_QML_DEBUG -DQT_DECLARATIVE_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../../../Programs/Qt/5.0.0/gcc/mkspecs/linux-g++ -I../Test -I../../../Programs/Qt/5.0.0/gcc/include -I../../../Programs/Qt/5.0.0/gcc/include/QtWidgets -I../../../Programs/Qt/5.0.0/gcc/include/QtGui -I../../../Programs/Qt/5.0.0/gcc/include/QtCore -I. -I. -I. -o widget.o ../Test/widget.cpp
/home/tom/Programs/Qt/5.0.0/gcc/bin/moc -DQT_QML_DEBUG -DQT_DECLARATIVE_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../../../Programs/Qt/5.0.0/gcc/mkspecs/linux-g++ -I../Test -I../../../Programs/Qt/5.0.0/gcc/include -I../../../Programs/Qt/5.0.0/gcc/include/QtWidgets -I../../../Programs/Qt/5.0.0/gcc/include/QtGui -I../../../Programs/Qt/5.0.0/gcc/include/QtCore -I. -I. -I. ../Test/widget.h -o moc_widget.cpp
g++ -c -pipe -g -Wall -W -D_REENTRANT -fPIE -DQT_QML_DEBUG -DQT_DECLARATIVE_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../../../Programs/Qt/5.0.0/gcc/mkspecs/linux-g++ -I../Test -I../../../Programs/Qt/5.0.0/gcc/include -I../../../Programs/Qt/5.0.0/gcc/include/QtWidgets -I../../../Programs/Qt/5.0.0/gcc/include/QtGui -I../../../Programs/Qt/5.0.0/gcc/include/QtCore -I. -I. -I. -o moc_widget.o moc_widget.cpp
g++ -Wl,-rpath,/home/tom/Programs/Qt/5.0.0/gcc -Wl,-rpath,/home/tom/Programs/Qt/5.0.0/gcc/lib -o Test main.o widget.o moc_widget.o -L/home/tom/Programs/Qt/5.0.0/gcc/lib -lQt5Widgets -lQt5Gui -lQt5Core -lGL -lpthread
/usr/bin/ld: cannot find -lGL
make: Leaving directory `/home/tom/Data/Qt5/Test-build-Desktop_Qt_5_0_0_GCC_32bit_SDK-Debug'
collect2: ld returned 1 exit status
make: *** [Test] Error 1
11:55:00: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project Test (kit: Desktop Qt 5.0.0 GCC 32bit (SDK))
When executing step 'Make'

amleto
25th December 2012, 16:38
take the GL dependency out of your pro file

tomkonikkara
26th December 2012, 01:34
take the GL dependency out of your pro file

Could you please tell how do I do that? I'm a newbie.

Jonny174
26th December 2012, 10:12
Add in pro file LIBS += -lGL

wysota
26th December 2012, 12:00
Could you please tell how do I do that? I'm a newbie.

Somewhere in your project file there is something similar to:

QT += opengl

Remove it and rerun qmake.

tomkonikkara
26th December 2012, 14:08
I tried both, but still not works.

This is my pro file:



#-------------------------------------------------
#
# Project created by QtCreator 2012-12-25T10:45:20
#
#-------------------------------------------------

QT += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = Test
TEMPLATE = app


SOURCES += main.cpp\
widget.cpp

HEADERS += widget.h

FORMS += widget.ui

wysota
26th December 2012, 19:58
It seems that by default QtWidgets requires OpenGL. In that case do you have OpenGL installed? Can you find a file called libGL.so in your system?

Viper666
27th December 2012, 13:11
Hi i have some problem my .pro
#-------------------------------------------------
#
# Project created by QtCreator 2012-12-27T13:59:39
#
#-------------------------------------------------

QT += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = untitled1
TEMPLATE = app


SOURCES += main.cpp\
mainwindow.cpp

HEADERS += mainwindow.h

FORMS += mainwindow.ui

ANd i have in system
libGL.so.1 and libGL.so.1.2.0
System: Linux Ubuntu 12.10

wysota
27th December 2012, 21:54
And why are you trying to hijack this thread instead of starting your own?

Viper666
28th December 2012, 10:20
Because author has same problems and he hasn't written nothing about 2 days.

wysota
28th December 2012, 12:28
We don't know if he has the same problem. You didn't even state what your problem was.

wysota
29th December 2012, 01:12
ANd i have in system
libGL.so.1 and libGL.so.1.2.0
System: Linux Ubuntu 12.10

BTW. You need libGL.so, not libGL.so.1. One should be a symlink to the other though (try running ldconfig as root and see if the link gets created).

ecanela
29th December 2012, 01:23
same problem using a fresh qt5 linux install.

I resolve this problem delete the -lGL option in the makefile generated in qmake. whis is a workaround but dor the moment works for me.

just search the -lGL option in Makefile and delete the text.

wysota
29th December 2012, 08:57
same problem using a fresh qt5 linux install.
This is not about Qt5. It is your system that is missing a library it is supposed to have. Reinstalling Qt won't help here. You need to install libmesa or accelerated NVIDIA drivers (in case you're using a NVIDIA card).

Hronom
18th May 2013, 11:57
Hello, I'm finded this problem on lubuntu 13.04 with Qt 5.0.2 when trying to compile my project with widgets and QtWebKit.
Solve this problem by writing command in terminal:

sudo apt-get install libglu1-mesa-dev

saman_artorious
19th May 2013, 14:56
sudo apt-get install libglu1-mesa-dev
Yes, every Ubuntu user needs to install this package before runnin opengl. This would have been very clear from the beginning if you had bothered to google the error..

wysota
19th May 2013, 22:00
Yes, every Ubuntu user needs to install this package before runnin opengl.

No, development packages are not required for running OpenGL.

kid9591
12th June 2013, 05:09
Hello, I'm finded this problem on lubuntu 13.04 with Qt 5.0.2 when trying to compile my project with widgets and QtWebKit.
Solve this problem by writing command in terminal:

sudo apt-get install libglu1-mesa-dev
Wonderful, thank you. it works for me.

mai7
18th September 2015, 19:14
/usr/bin/ld: cannot find -lGL

meaning the linker misses an OpenGL library.

This happens on fresh installs QT 5.5 on mint 17.2 cinnamon, for example. :confused:

I used synaptic-pack-installer to install

libglfw-dev
header files and static libraries portable framework for OpenGL application development

and

libglfw2
Shared libraries portable framework for OpenGL application development


and that causally fixed it. The wizard apps do build all of a sudden. :rolleyes: