Qt: can't find -lGL error - c++

I just reinstalled QtCreator, created new project (Qt Application) an got this after compilation:
/usr/bin/ld: **cannot find -lGL**
collect2: error: ld returned 1 exit status
make: *** [untitled1] Error 1
18:07:41: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project untitled1 (kit: Desktop Qt 5.1.0 GCC 32bit)
When executing step 'Make'
(Project is empty, I did'n commit any changes)
Qt Creator 2.7.2
Based on Qt 5.1.0 (32 bit)
Ubuntu 13.04
How do I solve this problem?

You should install package "libgl1-mesa-dev":
sudo apt install libgl1-mesa-dev

you don't need to install anything. libGL is already installed with Ubuntu, you just need to soft link it. (tested for ubuntu 14.x and 15.x, might work for later versions)
First locate the GL library
Then link it under /usr/lib
If the library is missing, it can be installed via libgl1-mesa-dev package
Here is how you could do this:
$ locate libGL
/usr/lib/i386-linux-gnu/mesa/libGL.so.1
/usr/lib/i386-linux-gnu/mesa/libGL.so.1.2.0
/usr/lib/x86_64-linux-gnu/libGLEW.so.1.10
/usr/lib/x86_64-linux-gnu/libGLEW.so.1.10.0
/usr/lib/x86_64-linux-gnu/libGLEWmx.so.1.10
/usr/lib/x86_64-linux-gnu/libGLEWmx.so.1.10.0
/usr/lib/x86_64-linux-gnu/libGLU.so.1
/usr/lib/x86_64-linux-gnu/libGLU.so.1.3.1
/usr/lib/x86_64-linux-gnu/mesa/libGL.so.1
/usr/lib/x86_64-linux-gnu/mesa/libGL.so.1.2.0
/usr/lib/x86_64-linux-gnu/mesa-egl/libGLESv2.so.2
/usr/lib/x86_64-linux-gnu/mesa-egl/libGLESv2.so.2.0.0
$ sudo ln -s /usr/lib/x86_64-linux-gnu/mesa/libGL.so.1 /usr/lib/libGL.so

The gui Qt module is included by default. If you don't want to use it in a project (e.g., it is a library or only uses stdio), you need to specify that in the .pro file.
QT -= gui
And the linker won't attempt to find lGL regardless of whether it is installed.
My case is admittedly a bit odd, since the main reason to use Qt is to create gui's. Installing the GL library is certainly not difficult, I just wanted to know why my quick and dirty Hello World wanted it.

write:
yum provides */libGL.so
after providing:
yum install mesa-libGL-devel mesa-libGLU-devel

This worked for me:
sudo ln -s /usr/lib/libEGL1.so /usr/lib/libGL.so

My system is Ubuntu 16.04 on x86 computer(with NVIDIA GeForce GPU).
Check the library files located in /usr/lib/x86_64-linux-gnu
ls -al /usr/lib/x86_64-linux-gnu/libG*
If you see the broken link, reinstall libgl1-mesa-glx
sudo apt install --reinstall libgl1-mesa-glx
And, recheck library.

In my case: I have installed QT 32 bit lib in Win10 64 bit and it ran into error, I change to all 64 bit and QT creator run smoothly.

Solved this problem just a minute ago in suse.
Just do the following step below and QTCreator should works just fine.
sudo zypper install --type pattern devel_basis

Related

Compiling 32bit Qt on 64bit Linux - fatal error: gnu/lib-names-32.h

Edit: I finally found the answer here. I'd been doing searches that were too specific and when I did a more general search I found that.
I'm trying to compile a 32bit version of Qt 5.6.2 on 64bit Linux Mint, but I'm getting the error fatal error: gnu/lib-names-32.h.
Just to go through what I've done, I used the below configuration command:
./configure -platform linux-g++-64 -xplatform linux-g++-32 -prefix /home/matthew/Qt/Qt5.6.2-S32 -static -opensource -confirm-license -make libs
I then built it with make -j4. I got some compilation errors which where solved by installing gcc-multilib and g++-multilib, but then ran into another error.
Searching for solutions to the latest error, most people suggest installing libx32gcc-4.8-dev and libc6-dev-i386, but I still get the same error.
Does anybody know what I need to install to build 32bt Qt on 64bit Linux Mint?
I finally found the answer here. I'd been doing searches that were too specific and when I did a more general search I found the answer.
You can try installing ia32 libs.
sudo aptitude install ia32-libs
Are you following a tutorial? If so, please, include the link. Could you also please explain your motivation to install 32b Qt libs on your 64b machine?
I had the same issue on the Linux Mint 18.3 x64, but all solutions found here did't solve the problem.
I've made some dig up and found that the only headers i have is these:
>find /usr/include -iname lib-names*
/usr/include/x86_64-linux-gnu/gnu/lib-names-64.h
/usr/include/x86_64-linux-gnu/gnu/lib-names.h
Seems this package (libc6-dev:amd64) is responsible for these files:
>dpkg -S /usr/include/x86_64-linux-gnu/gnu/lib-names-64.h
libc6-dev:amd64: /usr/include/x86_64-linux-gnu/gnu/lib-names-64.h
>dpkg -S /usr/include/x86_64-linux-gnu/gnu/lib-names.h
libc6-dev:amd64: /usr/include/x86_64-linux-gnu/gnu/lib-names.h
I've tried to remove it:
>sudo apt remove libc6-dev:amd64
... to DELETE:
build-essential g++ g++-5 g++-5-multilib g++-multilib gcc-5-multilib gcc-multilib lib32stdc++-5-dev libc6-dev
libc6-dev-i386 libc6-dev-x32 libstdc++-5-dev libx32stdc++-5-dev
If try to reinstall the deleted packages nothing would change. But if change one package just like that (libc6-dev:i386 instead of libc6-dev):
>sudo apt-get install build-essential g++ g++-5 g++-5-multilib g++-multilib gcc-5-multilib gcc-multilib lib32stdc++-5-dev libc6-dev:i386
libc6-dev-i386 libc6-dev-x32 libstdc++-5-dev libx32stdc++-5-dev
Now it has installed the required headers:
>find /usr/include -iname lib-names*
/usr/include/i386-linux-gnu/gnu/lib-names.h
/usr/include/i386-linux-gnu/gnu/lib-names-32.h
/usr/include/x86_64-linux-gnu/gnu/lib-names-64.h
/usr/include/x86_64-linux-gnu/gnu/lib-names.h
It looks like some dependency links are broken or not complete.

Error during project compilation in QT [duplicate]

I just reinstalled QtCreator, created new project (Qt Application) an got this after compilation:
/usr/bin/ld: **cannot find -lGL**
collect2: error: ld returned 1 exit status
make: *** [untitled1] Error 1
18:07:41: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project untitled1 (kit: Desktop Qt 5.1.0 GCC 32bit)
When executing step 'Make'
(Project is empty, I did'n commit any changes)
Qt Creator 2.7.2
Based on Qt 5.1.0 (32 bit)
Ubuntu 13.04
How do I solve this problem?
You should install package "libgl1-mesa-dev":
sudo apt install libgl1-mesa-dev
you don't need to install anything. libGL is already installed with Ubuntu, you just need to soft link it. (tested for ubuntu 14.x and 15.x, might work for later versions)
First locate the GL library
Then link it under /usr/lib
If the library is missing, it can be installed via libgl1-mesa-dev package
Here is how you could do this:
$ locate libGL
/usr/lib/i386-linux-gnu/mesa/libGL.so.1
/usr/lib/i386-linux-gnu/mesa/libGL.so.1.2.0
/usr/lib/x86_64-linux-gnu/libGLEW.so.1.10
/usr/lib/x86_64-linux-gnu/libGLEW.so.1.10.0
/usr/lib/x86_64-linux-gnu/libGLEWmx.so.1.10
/usr/lib/x86_64-linux-gnu/libGLEWmx.so.1.10.0
/usr/lib/x86_64-linux-gnu/libGLU.so.1
/usr/lib/x86_64-linux-gnu/libGLU.so.1.3.1
/usr/lib/x86_64-linux-gnu/mesa/libGL.so.1
/usr/lib/x86_64-linux-gnu/mesa/libGL.so.1.2.0
/usr/lib/x86_64-linux-gnu/mesa-egl/libGLESv2.so.2
/usr/lib/x86_64-linux-gnu/mesa-egl/libGLESv2.so.2.0.0
$ sudo ln -s /usr/lib/x86_64-linux-gnu/mesa/libGL.so.1 /usr/lib/libGL.so
The gui Qt module is included by default. If you don't want to use it in a project (e.g., it is a library or only uses stdio), you need to specify that in the .pro file.
QT -= gui
And the linker won't attempt to find lGL regardless of whether it is installed.
My case is admittedly a bit odd, since the main reason to use Qt is to create gui's. Installing the GL library is certainly not difficult, I just wanted to know why my quick and dirty Hello World wanted it.
write:
yum provides */libGL.so
after providing:
yum install mesa-libGL-devel mesa-libGLU-devel
This worked for me:
sudo ln -s /usr/lib/libEGL1.so /usr/lib/libGL.so
My system is Ubuntu 16.04 on x86 computer(with NVIDIA GeForce GPU).
Check the library files located in /usr/lib/x86_64-linux-gnu
ls -al /usr/lib/x86_64-linux-gnu/libG*
If you see the broken link, reinstall libgl1-mesa-glx
sudo apt install --reinstall libgl1-mesa-glx
And, recheck library.
In my case: I have installed QT 32 bit lib in Win10 64 bit and it ran into error, I change to all 64 bit and QT creator run smoothly.
Solved this problem just a minute ago in suse.
Just do the following step below and QTCreator should works just fine.
sudo zypper install --type pattern devel_basis

Error with homebrew + opencv + libpng

On Mac OS Maverick I have installed OpenCV with a brew install opencv.
I created a simple program (copied from this tutorial). Compilation worked fine but when running the executable I get the following error:
dyld: Library not loaded: /usr/local/lib/libpng16.16.dylib
Referenced from: /usr/local/lib/libopencv_highgui.2.4.dylib
Reason: Incompatible library version: libopencv_highgui.2.4.dylib requires version 33.0.0 or later, but libpng16.16.dylib provides version 32.0.0
Trace/BPT trap: 5
I checked that libpngwas properly installed via brew install libpng and ran a brew upgrade to make sure everything was up-to-date.
Running locate libpng16.dylib returns:
/Applications/GIMP.app/Contents/Resources/lib/libpng16.16.dylib
/usr/local/Cellar/libpng/1.6.10/lib/libpng16.16.dylib
/usr/local/Cellar/libpng/1.6.12/lib/libpng16.16.dylib
/usr/local/Cellar/libpng/1.6.13/lib/libpng16.16.dylib
/usr/local/Cellar/libpng/1.6.15/lib/libpng16.16.dylib
/usr/local/lib/libpng16.16.dylib
Any idea?
The best solution is to fully uninstall libpng and re-install it:
$ sudo brew uninstall libpng
$ sudo rm '/usr/local/bin/libpng-config'
$ for i in `brew link --overwrite --dry-run libpng`; do sudo rm $i; done
$ sudo brew install libpng
If you need to install opencv:
$ sudo brew tap homebrew/science
$ sudo brew install opencv
Homebrew should ensure that you the correct dependencies install. However, it's possible that you have more than one version of libpng16 installed at different paths. Have a look in...
/usr/lib
/opt/local/lib
If you find any versions of the library in these locations then they may be causing the wrong one to be loaded when your program starts. As a quick fix you can try typing DYLD_LIBRARY_PATH=/usr/local/lib before your program name on the command line. In the longer term you may need to remove the conflicting versions altogether.
This answer is for OSX users who installed through Conda, more specifically the conda-forge channel (I'm not sure about others).
Conda ends up installing its own libpng in the environment and you can update it with conda upgrade libpng.
I guess this is basically a bug with the opencv recipe on conda-forge.

How to compile with FLTK under Ubuntu

I am using Code:blocks under Ubuntu 12.04 LTS. I am attempting to compile my first program using FLTK and I get the following errors.
Linking console executable: bin/Debug/<project name removed for security reasons>
/usr/bin/ld: cannot find -lXft
/usr/bin/ld: cannot find -lfontconfig
/usr/bin/ld: cannot find -lfontconfig
/usr/bin/ld: cannot find -lXinerama
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 0 seconds)
4 errors, 0 warnings
Is there something else I need to install, or a path I need to add?
To build an FLTK project in Code::Blocks 16.01 on UBUNTU 16.04.
Install FLTK and two additional packages:
$ sudo apt install fltk1.3-dev
$ sudo apt install libxft-dev
$ sudo apt install libxinerama-dev
After this, you can define an FLTK project, and build it without problems.
If you do not install the libxft-dev and libXinerama-dev packages, you will indeed get these error messages listed in question about missing libraries (-lXft, -lfontconfig, -lXinerama).
The reason these packages are not installed automatically with fltk1.3-dev is because they're only 'suggested', and not a hard dependency. This can be seen here:
package: libfltk1.3-dev
However, the 'fltk-config' flag which is used by Code:Blocks to decide what libraries to link in requires them.
For more detail on the fltk-config flag, see:
Beginners Guide to fltk-config
For completeness, here the links to the 2 additional packages:
package: libxft-dev
package: libxinerama-dev
The dev version of libraries used by FLTK might be missing http://packages.ubuntu.com/precise/libfltk1.3 .
You can use apt-get to install them : libxft-dev, libfontconfig1-dev and libxinerama-dev.
You obviously do not have libXft, libfontconfig and libXinerama installed on your machine. If you installed FLTK using Ubuntu package manager, then you should report missing dependency information in the FLTK package.
Typically we do this by finding out who is the package maintainer, and send e-mail to that person.
I managed to get code:blocks 13.12 working with FTLK on Raspberry Pi using Raspian. CodeBlocks gave me those same errors "cannot find -lXft" "cannot find -lfontconfig" and "cannot find -lXinerama".
I used the add/remove software provided with Raspian and searched for each of the following libraries libxft-dev, libfontconfig1-dev and libxinerama-dev and then I installed them using the package manager. When I restarted codeblocks FLTK worked fine!

Failed to compile wxWidgets-2.9.2 on Kubuntu11.10(64bit) with '--with-opengl' flag

I tried to compile wxWidgets-2.9.2 with opengl support by calling
configure --with-opengl
But it failed when the configure script tried to locate the lib files of opengl
checking for GL/gl.h... yes
checking for GL/glu.h... yes
checking for -lGL... no
checking for -lMesaGL... no
configure: error: OpenGL libraries not available
However, I checked /usr/lib and found that there is libGL.so in that directory. Actually, before trying to compile wxWidgets-2.9.2, I had written several opengl programs and all were successfully compiled and run. Could someone help me to fix this?
This is actually a bug in the configure script, please see
http://trac.wxwidgets.org/ticket/13375.
The solution is to download the latest codes from
http://svn.wxwidgets.org/svn/wx/wxWidgets/trunk/
Or you can select to overwrite only the configure,acinclude.m4 files.
Have you tried installing the free implementation?
sudo apt-get install libglw1-mesa libglw1-mesa-dev
Are you running proprietary drivers from Nvidia or something? I think it messes around with the OpenGL environment while installing. Perhaps, it is worth trying to go back the the opensource ones if this is the case.
There is also a know issue OpenGL libs not located by 'configure' in debian testing
First of all check if opengl libs are installed! them --->
we need to change Configure file on source! check this link:
http://trac.wxwidgets.org/ticket/13376
the same issues arise on ubuntu 12.04!
I also met the same problem when trying to compile wxWidgets3.1.0 --with-opengl on Debian Jessie x86_64. I tried
SEARCH_LIB="`echo "$SEARCH_INCLUDE" | sed s#include#$wx_cv_std_libpath#g` /usr/$
wx_cv_std_libpath /usr/lib/i386-linux-gnu /usr/lib/x86_64-linux-gnu"
and
pkg-config --variable=libdir gl
/usr/lib/x86_64-linux-gnu
and
sudo apt-get install libglw1-mesa libglw1-mesa-dev
but:
OpenGL libraries not available
I then tried
sudo apt-get install glutg3-dev
but:
glutg3-dev is not found.
So I searched for the alternative to glutg3-dev in Jessie and I tried
sudo apt-get install freeglut3-dev
then it worked!
Installing mesa didn't help for me, but installing glutg3-dev did the trick
sudo apt-get install glutg3-dev