EDIT:
After a bit more digging I have found that I have a libGL.so at /usr/lib/i386-linux-gnu/libGL.so
and if I move this away then linking works correctly again. After looking at the error line for a while I thought that the full path to libGL.so in the message was suspicious because it would have been looking at multiple locations to find it and usually it only shows the name of the library not one specific full path. So the question now is; why did finding the other version cause the search to stop and show a confusing error message? (I'm the i386ness made it incompatible in some way).
ORIG:
For some reason I am having trouble linking in libGL.so into my application. The issue seems to be that ld (or gold in this case) is not looking in /usr/lib (which from everything I can find is one of the default locations) when trying to find it instead it is looking in a bit of a whacky location e.g.
/usr/bin/ld: error: cannot open /usr/lib/gcc/i686-linux-gnu/4.7/../../../i386-linux-gnu/libGL.so: No such file or directory
Now /usr/lib/libGL.so definitely exists and I if I do an explicit -L/usr/lib in the makefile everything links correctly.
I'm wondering does anyone know what is going on here?
Info:
Ubuntu linux 12.10 x86
g++ 4.7
GNU gold linker
CPU AMD Phenom 2 x6
uname -m out: i686
EDIT: Output of link with -v parameter:
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/i686-linux-gnu/4.7/lto-wrapper
Target: i686-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.7.2-2ubuntu1' --with-bugurl=file:///usr/share/doc/gcc-4.7/README.Bugs --enable-languages=c,c++,go,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.7 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.7 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --enable-objc-gc --enable-targets=all --disable-werror --with-arch-32=i686 --with-tune=generic --enable-checking=release --build=i686-linux-gnu --host=i686-linux-gnu --target=i686-linux-gnu
Thread model: posix
gcc version 4.7.2 (Ubuntu/Linaro 4.7.2-2ubuntu1)
COMPILER_PATH=/usr/lib/gcc/i686-linux-gnu/4.7/:/usr/lib/gcc/i686-linux-gnu/4.7/:/usr/lib/gcc/i686-linux-gnu/:/usr/lib/gcc/i686-linux-gnu/4.7/:/usr/lib/gcc/i686-linux-gnu/
LIBRARY_PATH=/usr/lib/gcc/i686-linux-gnu/4.7/:/usr/lib/gcc/i686-linux-gnu/4.7/../../../i386-linux-gnu/:/usr/lib/gcc/i686-linux-gnu/4.7/../../../../lib/:/lib/i386-linux-gnu/:/lib/../lib/:/usr/lib/i386-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/i686-linux-gnu/4.7/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-o' 'application' '-v' '-L/home/user/src/tutorials/application/builds/./vendor/ogre3d/./lib' '-shared-libgcc' '-mtune=generic' '-march=i686'
/usr/lib/gcc/i686-linux-gnu/4.7/collect2 --sysroot=/ --build-id --no-add-needed --as-needed --eh-frame-hdr -m elf_i386 --hash-style=gnu -dynamic-linker /lib/ld-linux.so.2 -z relro -o application /usr/lib/gcc/i686-linux-gnu/4.7/../../../i386-linux-gnu/crt1.o /usr/lib/gcc/i686-linux-gnu/4.7/../../../i386-linux-gnu/crti.o /usr/lib/gcc/i686-linux-gnu/4.7/crtbegin.o -L/home/user/src/tutorials/application/builds/./vendor/ogre3d/./lib -L/usr/lib/gcc/i686-linux-gnu/4.7 -L/usr/lib/gcc/i686-linux-gnu/4.7/../../../i386-linux-gnu -L/usr/lib/gcc/i686-linux-gnu/4.7/../../../../lib -L/lib/i386-linux-gnu -L/lib/../lib -L/usr/lib/i386-linux-gnu -L/usr/lib/../lib -L/usr/lib/gcc/i686-linux-gnu/4.7/../../.. /home/user/src/tutorials/application/builds/./src/most_basic_main.o /home/user/src/tutorials/application/builds/./src/QOgreWidget.o /home/user/src/tutorials/application/builds/./src/QtOgreApplication.o /home/user/src/tutorials/application/builds/./src/qt_gen/QtOgreApplication.moc.o /home/user/src/tutorials/application/builds/./src/qt_gen/QOgreWidget.moc.o -lpthread -lQtCore -lQtNetwork -lQtGui -lQtOpenGL -lRenderSystem_GLStatic -lOgreMainStatic -ldl -lfreetype -lXrandr -lGL -lGLU -lxcb -lX11 -lXext -lXpm -lXaw7 -lXt -lzzip -lfreeimage -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/lib/gcc/i686-linux-gnu/4.7/crtend.o /usr/lib/gcc/i686-linux-gnu/4.7/../../../i386-linux-gnu/crtn.o
/usr/bin/ld: error: cannot open /usr/lib/gcc/i686-linux-gnu/4.7/../../../i386-linux-gnu/libGL.so: No such file or directory
uname -m
. – IneQuationLIBRARY_PATH
doesn't include/usr/lib
. I'm not sure what sets it, but that should point you where to look. – IneQuation:/usr/lib/
right at the end of theLIBRARY_PATH
line? – radman