Qt cannot find libGL

I am attempting to learn Qt and am attempting to use the QGraphicsView but when I compile I get this error:


:-1: error: skipping incompatible /usr/lib/libGL.so when searching for -lGL
:-1: error: cannot find -lGL
:-1: error: collect2: error: ld returned 1 exit status

I searched around and it seems to have something to do with 64bit/32bit packages, I have gcc which is 64bit and I installed mesa-devel which I assume is also 64bit. The only 32bit thing I can think of is perhaps the 32 bit libraries the nvidia installer asks to add tot he system (which I said yes to). Any guidance would be appreciated.

ps: It is probably some simple problem but its 3 am here so I am feeling a bit tired, hopefully when I wake up someone will have left the answer to my problem here :wink:

For -lGL you need to install Mesa-libGL-devel.

But, according to your error message:

you seem to have the i586 version of Mesa-libGL-devel installed. This won’t work!
You need to install the x86_64 version.

Use “rpm -q Mesa-libGL-devel” to check, or the “Versions” tab in YaST.

If you want to build a 32bit application, you should additionally install Mesa-libGL-devel-32bit, this is co-installable with the 64bit Mesa-libGL-devel.


~> rpm -q Mesa-libGL-devel
Mesa-libGL-devel-9.2.3-61.9.1.x86_64
~> rpm -q gcc 
gcc-4.8-2.1.2.x86_64

Strange, does that mean its trying to compile for 32 bit systems? I dont recall changing any settings related to that. :sarcastic:

I installed the 32 bit version of the devel package and now I get this:


:-1: error: cannot find -lGL
:-1: error: collect2: error: ld returned 1 exit status

So there was some progress… rotfl!

How exactly are you trying to compile that application?
It seems like your linker path is set wrong.

But I still find it strange that you would get “skipping incompatible /usr/lib/libGL.so when searching for -lGL” when /usr/lib/libGL.so isn’t installed, but “cannot find -lGL” when it is…:open_mouth:

I am using Qt Creator, so whatever its default settings are for the kits, thats what I am using.

Something interesting here though


~> ll /usr/lib/libGL.so
lrwxrwxrwx 1 root root 14 Apr 28 14:53 /usr/lib/libGL.so -> libGL.so.1.2.0

~> ll /usr/lib/libGL.so.1.2.0
ls: cannot access /usr/lib/libGL.so.1.2.0: No such file or directory

~> ldd /usr/bin/glxgears
        linux-vdso.so.1 (0x00007fff00dfe000)
**        libGL.so.1 => /usr/lib64/libGL.so.1 (0x00007fbe9302f000)**
        libm.so.6 => /lib64/libm.so.6 (0x00007fbe92d2c000)
        libX11.so.6 => /usr/lib64/libX11.so.6 (0x00007fbe929ee000)
        libc.so.6 => /lib64/libc.so.6 (0x00007fbe9263f000)
        libnvidia-tls.so.331.67 => /usr/lib64/tls/libnvidia-tls.so.331.67 (0x00007fbe9243c000)
        libnvidia-glcore.so.331.67 => /usr/lib64/libnvidia-glcore.so.331.67 (0x00007fbe8fc2d000)
        libXext.so.6 => /usr/lib64/libXext.so.6 (0x00007fbe8fa1b000)
        libdl.so.2 => /lib64/libdl.so.2 (0x00007fbe8f817000)
        libxcb.so.1 => /usr/lib64/libxcb.so.1 (0x00007fbe8f5f8000)
        /lib64/ld-linux-x86-64.so.2 (0x00007fbe93362000)
        libXau.so.6 => /usr/lib64/libXau.so.6 (0x00007fbe8f3f4000)

:expressionless:

Are you compiling one of the examples?
This shouldn’t be compiled as 32bit application then on a 64bit system with the default settings.

Where did you install Qt Creator from though?
Is it the one included in openSUSE?

Something interesting here though

~> ll /usr/lib/libGL.so
lrwxrwxrwx 1 root root 14 Apr 28 14:53 /usr/lib/libGL.so → libGL.so.1.2.0

~> ll /usr/lib/libGL.so.1.2.0
ls: cannot access /usr/lib/libGL.so.1.2.0: No such file or directory

OK, that explains why /usr/lib/libGL.so wasn’t found.

You need to install Mesa-libGL-32bit as well.
But I thought that should be installed automatically if it was required…

Its just some tutorial I am following, nothing complicated.
I initially attempted to install qtcreator from the repos but that was causing issues so i just downloaded and installed it from the qt community site.

There is no such package as Mesa-libGL-32bit


> se Mesa-libGL1-32bit  
Loading repository data...
Reading installed packages...

S | Name              | Type    | Version      | Arch   | Repository          
--+-------------------+---------+--------------+--------+---------------------
i | Mesa-libGL1-32bit | package | 9.2.3-61.9.1 | x86_64 | openSUSE-13.1-Update
v | Mesa-libGL1-32bit | package | 9.2.2-61.6.1 | x86_64 | openSUSE-13.1-Oss   


~> se Mesa-libGL-devel
Loading repository data...
Reading installed packages...

S | Name                   | Type    | Version      | Arch   | Repository          
--+------------------------+---------+--------------+--------+---------------------
i | Mesa-libGL-devel       | package | 9.2.3-61.9.1 | x86_64 | openSUSE-13.1-Update
v | Mesa-libGL-devel       | package | 9.2.2-61.6.1 | x86_64 | openSUSE-13.1-Oss   
v | Mesa-libGL-devel       | package | 9.2.3-61.9.1 | i586   | openSUSE-13.1-Update
v | Mesa-libGL-devel       | package | 9.2.2-61.6.1 | i586   | openSUSE-13.1-Oss   
i | Mesa-libGL-devel-32bit | package | 9.2.3-61.9.1 | x86_64 | openSUSE-13.1-Update
v | Mesa-libGL-devel-32bit | package | 9.2.2-61.6.1 | x86_64 | openSUSE-13.1-Oss

I think the problem is the broken link.

And what kind of issues?
It worked fine here whenever I used it.

I suppose that the version you installed has a wrong default linker path, i.e. just /usr/lib/ and not /usr/lib64/ as used on openSUSE-64bit.

There is no such package as Mesa-libGL-32bit

Sorry, that was a typo.
I meant Mesa-libGL1-32bit of course, but you have that installed anyway.

I think the problem is the broken link.

Yes it is, if you wanted to compile for 32bit. But for doing that you would also need to specify some additional compiler flags.

To fix the broken link, you should try to re-install “Mesa-libGL1-32bit”:

sudo zypper in -f Mesa-libGL1-32bit

This is what should contain /usr/lib/libGL.so.1.2.0.

But your real problem is the wrong linker path I think.
Where do you actually have “qmake” installed from?

rpm -qif `which qmake`

Qt-Creator’s qmake settings should look like this: (click on “Details”)
http://wstaw.org/m/2014/04/28/qtcreator.png

Maybe “QT_INSTALL_LIBS” is set to /usr/lib in your case? Try to change all of them to the values above, those are the defaults of the openSUSE package.

It seems the issue stems from the nvidia driver. I removed it and now I can compile the program just fine.

Thank you for the help wolfi :slight_smile:

Oh.
I did have this in mind at first, but then I really thought you should be able to compile libGL applications with the nvidia driver installed.
Hm.
As I don’t have an nvidia system, I cannot really help you there, sorry.

But another question. How did you actually install the nvidia driver?
If it was by “the hard way”, it just overwrites libGL with its own version, so that might explain it.

Yeah it was the hard way so thats probably why (using 3.14 so cant rely on the repo version). :shame:

But now nouveau isnt activating on boot, and I am pretty sure its not blacklisted (did a grep on all the files in xorg.conf.d and didnt see anything).

As the blacklist is about the kernel module, it would be in /etc/modprobe.d/.
Also check that you don’t have “nomodeset” amongst your kernel boot options.

And /etc/sysconfig/kernel should contain NO_KMS_IN_INITRD=“no”. You have to run mkinitrd after you change that though.

:expressionless: why did I think it was xorg.conf.d/