PDA

View Full Version : Linker warning: libz.so.1 not found



CraigD
3rd October 2012, 16:21
Hello,
I am attempting to write a small console app in QtCreator on openSuse Linux 12.2 (using the version provided by the distro 2.5.0). The application simply
connects to a small SQLite database and reads some data from a table.

Compiling works fine, but when it tries to link I get errors along the following lines:



/usr/lib64/gcc/x86_64-suse-linux/4.7/../../../../x86_64-suse-linux/bin/ld: warning: libz.so.1, needed by /usr/lib64/libQtCore.so, not found (try using -rpath or -rpath-link)
/usr/lib64/gcc/x86_64-suse-linux/4.7/../../../../x86_64-suse-linux/bin/ld: warning: libdl.so.2, needed by /usr/lib64/libQtCore.so, not found (try using -rpath or -rpath-link)
/usr/lib64/gcc/x86_64-suse-linux/4.7/../../../../x86_64-suse-linux/bin/ld: warning: librt.so.1, needed by /usr/lib64/libQtCore.so, not found (try using -rpath or -rpath-link)
/usr/lib64/gcc/x86_64-suse-linux/4.7/../../../../x86_64-suse-linux/bin/ld: warning: libglib-2.0.so.0, needed by /usr/lib64/libQtCore.so, not found (try using -rpath or -rpath-link)


All the libraries that ld reports as missing are installed and in my ld path. For example:


> ls /lib64/libz*
/lib64/libz.so.1 /lib64/libz.so.1.2.7

According to ldconfig /lib64 is in the ld search path. The contents of ld.so.conf are:


usr/local/lib64
/usr/local/lib
include /etc/ld.so.conf.d/*.conf
# /lib64, /lib, /usr/lib64 and /usr/lib gets added
# automatically by ldconfig after parsing this file.
# So, they do not need to be listed.


Thanks for any ideas on what the problem might be.

Cheers,

Craig

PS. I don't expect an answer to this as it is a bit OT, but since I was curious - does anyone know why the convoluted search path to call ld, and not just /usr/x86_64-suse-linux/bin/ld? This isn't a Qt issue, but seems to be the way the gcc toolchain is setup on openSuse.

wysota
3rd October 2012, 17:42
/usr/lib64/gcc/x86_64-suse-linux/4.7/../../../../x86_64-suse-linux/bin/ld: warning: libz.so.1, needed by /usr/lib64/libQtCore.so, not found (try using -rpath or -rpath-link)
/usr/lib64/gcc/x86_64-suse-linux/4.7/../../../../x86_64-suse-linux/bin/ld: warning: libdl.so.2, needed by /usr/lib64/libQtCore.so, not found (try using -rpath or -rpath-link)
/usr/lib64/gcc/x86_64-suse-linux/4.7/../../../../x86_64-suse-linux/bin/ld: warning: librt.so.1, needed by /usr/lib64/libQtCore.so, not found (try using -rpath or -rpath-link)
/usr/lib64/gcc/x86_64-suse-linux/4.7/../../../../x86_64-suse-linux/bin/ld: warning: libglib-2.0.so.0, needed by /usr/lib64/libQtCore.so, not found (try using -rpath or -rpath-link)


All the libraries that ld reports as missing are installed and in my ld path. For example:


> ls /lib64/libz*
/lib64/libz.so.1 /lib64/libz.so.1.2.7

According to ldconfig /lib64 is in the ld search path. The contents of ld.so.conf are:


usr/local/lib64
/usr/local/lib
include /etc/ld.so.conf.d/*.conf
# /lib64, /lib, /usr/lib64 and /usr/lib gets added
# automatically by ldconfig after parsing this file.
# So, they do not need to be listed.

Run ldd on those libs that report missing symbols (e.g. /usr/lib64/libQtCore.so) and see if the linker is able to find your libz and others.


PS. I don't expect an answer to this as it is a bit OT, but since I was curious - does anyone know why the convoluted search path to call ld, and not just /usr/x86_64-suse-linux/bin/ld? This isn't a Qt issue, but seems to be the way the gcc toolchain is setup on openSuse.
Because you might have more than one set of binutils installed on your machine and the build process wants to make sure it calls the right one (through the use of symbolic links).

CraigD
3rd October 2012, 19:14
Run ldd on those libs that report missing symbols (e.g. /usr/lib64/libQtCore.so) and see if the linker is able to find your libz and others.

From running ldd I get the following.

Everything seems to be there (I checked and libQtCore.so is a symlink to libQtCore.so.4.8.1).



ldd libQtCore.so.4.8.1
linux-vdso.so.1 (0x00007fff0b400000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f045ece8000)
libz.so.1 => /lib64/libz.so.1 (0x00007f045ead0000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007f045e8c8000)
librt.so.1 => /lib64/librt.so.1 (0x00007f045e6c0000)
libglib-2.0.so.0 => /usr/lib64/libglib-2.0.so.0 (0x00007f045e3c8000)
libstdc++.so.6 => /usr/lib64/libstdc++.so.6 (0x00007f045e0c0000)
libm.so.6 => /lib64/libm.so.6 (0x00007f045ddc8000)
libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f045dbb0000)
libc.so.6 => /lib64/libc.so.6 (0x00007f045d808000)
/lib64/ld-linux-x86-64.so.2 (0x00007f045ef08000)
libpcre.so.1 => /usr/lib64/libpcre.so.1 (0x00007f045d5a8000)


Do you see anything fishy there?

Cheers,
Craig

wysota
3rd October 2012, 19:17
Does the compilation work if you do it from the command line and not from QtCreator?

CraigD
3rd October 2012, 20:09
Does the compilation work if you do it from the command line and not from QtCreator?

I went to the project directory and did the following:



>qmake sqlite_props.pro
>gmake


It spits out the following (main.cpp and propertyfile.cpp are the two source files for my project):



g++ -c -m64 -pipe -O2 -Wall -W -D_REENTRANT -DQT_WEBKIT -DQT_NO_DEBUG -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/default -I. -I/usr/include/QtCore -I/usr/include -I. -o main.o main.cpp
g++ -c -m64 -pipe -O2 -Wall -W -D_REENTRANT -DQT_WEBKIT -DQT_NO_DEBUG -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/default -I. -I/usr/include/QtCore -I/usr/include -I. -o propertyfile.o propertyfile.cpp
g++ -m64 -Wl,-O1 -o sqlite_props main.o propertyfile.o -L/usr/lib64 -lQtCore -L/usr/lib64 -lpthread
/usr/lib64/gcc/x86_64-suse-linux/4.7/../../../../x86_64-suse-linux/bin/ld: warning: libz.so.1, needed by /usr/lib64/libQtCore.so, not found (try using -rpath or -rpath-link)
/usr/lib64/gcc/x86_64-suse-linux/4.7/../../../../x86_64-suse-linux/bin/ld: warning: libdl.so.2, needed by /usr/lib64/libQtCore.so, not found (try using -rpath or -rpath-link)
/usr/lib64/gcc/x86_64-suse-linux/4.7/../../../../x86_64-suse-linux/bin/ld: warning: librt.so.1, needed by /usr/lib64/libQtCore.so, not found (try using -rpath or -rpath-link)
/usr/lib64/gcc/x86_64-suse-linux/4.7/../../../../x86_64-suse-linux/bin/ld: warning: libglib-2.0.so.0, needed by /usr/lib64/libQtCore.so, not found (try using -rpath or -rpath-link)


Cheers,
Craig

wysota
3rd October 2012, 20:55
Does it work if you add the following entry to the project file?

LIBS += -L/lib64

By the way, how did you install Qt?

CraigD
3rd October 2012, 21:19
Does it work if you add the following entry to the project file?

LIBS += -L/lib64

By the way, how did you install Qt?

Adding the LIBS to the project file did not change any of the error messages.

I installed the libraries included with the distro (openSuse 12.2 ) through Yast.

Checking through my list of installed packages I noticed that I have both libqt4 and libqt4-32bit installed, could this be part of the problem?

Cheers,

Craig

wysota
3rd October 2012, 21:44
I installed the libraries included with the distro (openSuse 12.2 ) through Yast.
If you use standard repositories and this is happening then I suggest looking if anyone else with openSuse 12.2 had a similar problem. It seems like an issue with distro packages.


Checking through my list of installed packages I noticed that I have both libqt4 and libqt4-32bit installed, could this be part of the problem?
I don't think so. The messages clearly indicate you are using 64b libs.

CraigD
3rd October 2012, 22:20
Thanks. I am taking my troubles to the openSuse forums.

If I can find out what went wrong I will post here for the education of future generations ...

Cheers,
Craig

CraigD
4th October 2012, 18:55
With some help on the openSuse form. I seem to have found a solution to my problem, but it looks like it was my mis-use of QtCreator that was the problem.

I added the following lines to my .pro file, after which a call to qmake and gmake did the trick.



QT += sql
LIBS += -lz -ldl -lrt -lglib-2.0 -lpcre


I am surprised I had to explicitly add the -lz -ldl -lrt -lglib-2.0 -lpcre to my .pro file.

Can anyone explain why it is necessary to specifically link to these libraries which are already in the path.

Perhaps the fact that I didn't initially specify QT += sql caused this.

Anyway, hope this helps if anyone else stumbles across the same problem in the future.

Cheers,

Craig

wysota
4th October 2012, 19:47
I am surprised I had to explicitly add the -lz -ldl -lrt -lglib-2.0 -lpcre to my .pro file.
You shouldn't need to do that unless you are using static libraries.


Can anyone explain why it is necessary to specifically link to these libraries which are already in the path.
It's not necessary.


Perhaps the fact that I didn't initially specify QT += sql caused this.
That's very unlikely.

pinguin74
26th January 2013, 01:00
Hello Craig,

I ran exactly into the same problem like you and like you I use openSUSE 12.2. But I do not try to build Qt software, I tried to build the media center software XBMC. I get the same errors like you, the linker cannot find libraried, although they are installed on the system.

I get errors like this:


/usr/lib64/gcc/x86_64-suse-linux/4.7/../../../../x86_64-suse-linux/bin/ld:
warning: libm.so.6, needed by /usr/lib64/libpython2.7.so, not found (try
using -rpath or -rpath-link)

Actually libm.so.6 is there. My guess was the linker in openSUSE is broken. But, the amazing thing is, other folks can build XBMC on openSUSE 12.2, so it leaves me totally clueless.

What would I have to do to adapt your solution to my problem? Actually it seems we have the very same problem, only difference you build Qt code and I try to build XBMC.

addendum
I have now removed all binutil packages that I do not need, e.g. for ARM, IA64 and so on, I only kept binutils for x86_64 and i386 and suddenly I can build the software now! Can this really be the root of the problem? Does having several binutils on the system make the system weird? All I can say it works now, all I did was to remove unneeded binutils.

Thanx
Malte