5

I have freshly installed Fedora 19 x86_64 on my PC. I wrote a simple OpenGL program, but failed to compile it.

    gcc -o quad quad.c -lX11 -lGL -lGLU
    /usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-redhat-linux/4.8.1/../..        /../libGL.so when searching for -lGL
    /usr/bin/ld: skipping incompatible /lib/libGL.so when searching for -lGL
    /usr/bin/ld: skipping incompatible /usr/lib/libGL.so when searching for -lGL
    /usr/bin/ld: cannot find -lGL
    collect2: error: ld returned 1 exit status

I have MesaGL and other libraries in place (i.e. /usr/lib) then what's wrong ?

Manmohan Bishnoi
  • 791
  • 13
  • 37
  • Have you installed any additional GL libs, perhaps through an ATI or NVIDIA graphics driver install? – JonnyRo Jul 09 '13 at 15:32
  • Yes I installed ATI Catalyst Drivers v 13.6 beta. – Manmohan Bishnoi Jul 09 '13 at 15:32
  • The dark side of both the NVIDIA and ATI installers is that they REPLACE the GL libs. – JonnyRo Jul 09 '13 at 15:48
  • You are also running ccache, which I would recommend against until you have resolved the issue. It /shouldnt/ matter but I would suggest limiting the points at which the process could break. – JonnyRo Jul 09 '13 at 15:49

4 Answers4

6

For me, something was wrong with the library symlinks:

$ locate libGL.so | egrep ^/usr | xargs file
/usr/lib/libGL.so:                     symbolic link to `/usr/lib/libGL.so.1'
/usr/lib/libGL.so.1:                   symbolic link to `/usr/lib/libGL.so.1.2'
/usr/lib/libGL.so.1.2:                 symbolic link to `/usr/lib/fglrx/fglrx-libGL.so.1.2'
/usr/lib/fglrx/fglrx-libGL.so.1.2:     ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), dynamically linked, stripped
/usr/lib64/FGL.renamed.libGL.so.1.2.0: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=46121ec8b16424a8b65a0cf11c3f9730ae0e49f5, stripped
/usr/lib64/libGL.so:                   broken symbolic link to `libGL.so.1.2.0'
/usr/lib64/libGL.so.1:                 symbolic link to `/usr/lib64/libGL.so.1.2'
/usr/lib64/libGL.so.1.2:               symbolic link to `/usr/lib64/fglrx/fglrx-libGL.so.1.2'
/usr/lib64/fglrx/fglrx-libGL.so.1.2:   ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, stripped

So /usr/lib/libGL.so pointed at a 32-bit lib and /usr/lib/libGL.so was a broken link. I fixed the /usr/lib64 version to point correctly at libGL.so.1 (and the /usr/lib version to point at the 64 bit version for good measure) and this seems to have gotten my code compiling.

sirbrialliance
  • 3,612
  • 1
  • 25
  • 15
  • I have the same problem, Could you please tell me how exactly you fixed the /usr/lib64 version to point correctly at libGL.so.1? – Dino Jun 27 '17 at 07:56
  • Remove the bad link, then recreate it pointing to the correct file with `ln -s` – sirbrialliance Jun 28 '17 at 15:06
  • I'm in the same occasion with you and I solved this problem in your way. But do you have any idea about why is this happening? I didn't do anything after I installed MesaGL. And it just happened when I try to compile. – Cosmo Jan 16 '19 at 05:26
1

There are warnings about incompatible versions of libGL, and also about incompatible GCC libraries. I think you might have a 32 bit version of gcc installed on a 64-bit OS. Try

file -L `which gcc`

to check on this.

Ernest Friedman-Hill
  • 80,601
  • 10
  • 150
  • 186
  • That's the output of the "which" command, but not the whole pipeline I've shown, which should say something more like "64-bit ELF executable" – Ernest Friedman-Hill Jul 09 '13 at 15:33
  • my bad, /usr/lib64/ccache/gcc: symbolic link to `../../bin/ccache' – Manmohan Bishnoi Jul 09 '13 at 15:34
  • /usr/lib64/ccache/gcc: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=0xcc138400640fee53799c8e85ffa20df35843d246, stripped – Manmohan Bishnoi Jul 09 '13 at 15:36
  • I'd run the file -L command on the GL lib it is attempting to link against, very curious to see what the output is. – JonnyRo Jul 09 '13 at 15:50
1

The problem is fixed.

I removed ATI Catalyst Driver v13.6 beta by executing "aticonfig --uninstall" REBOOT compile the program with same commands, and it was success :)

Now I reinstalled ATI Catalyst Drivers v13.6 beta REBOOT and compile the program again, It builds SUCCESSFULLY !!

Don't know what was wrong, but I have OpenGL working now :)

Manmohan Bishnoi
  • 791
  • 13
  • 37
-2

Install freeglut-devel : # sudo yum install freeglut-devel

igb
  • 1