/usr/bin/ld: cannot find -ldb while compiling iproute2
As @bersh astutely points out in comments, you appear to be mixing libraries that have been compiled for different architectures (32-bit vs. 64-bit). On Fedora 32-bit libraries go in the /usr/lib
, while 64-bit libraries go in /usr/lib64
. You can convince yourself of this with a couple of examples.
Example
Let's pick on one of the share libraries for the DNS resolver, /usr/lib/libresolv-2.17.so
. We can see that it's part of a 32-bit RPM.
$ rpm -qf /usr/lib/libresolv-2.17.so
glibc-2.17-20.fc19.i686
You can also see that the library is a 32-bit ELF headered file.
$ file /usr/lib/libresolv-2.17.so
/usr/lib/libresolv-2.17.so: ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), BuildID[sha1]=0xeee8b9e6cb49f8dd64059cc158ce2c55f8c6df5b, for GNU/Linux 2.6.32, not stripped
So you need to take care when compiling your software to make sure that you have the appropriate libraries in place (32 & 64) as well as the corresponding header files. On Fedora (and all Red Hat based distros) the packages are named like so:
- 32-bit - libdb-5.3.21-11.fc19.i686
- 64-bit - libdb-5.3.21-11.fc19.x86_64
- 32-bit header files - libdb-devel-5.3.21-11.fc19.i686
- 64-bit header files - libdb-devel-5.3.21-11.fc19.x86_64
Your library, libdb
If you notice the library file is available in both architectures. Given the output of your kernel
package being x64, I would assume you meant to install the 64-bit versions of the libraries.
Also since you're attempting to compile you'll want to install the header files for your architecture too.
$ rpm -qf /usr/lib/libdb-5.3.so
libdb-5.3.21-11.fc19.i686
$ rpm -qf /usr/lib64/libdb-5.3.so
libdb-5.3.21-11.fc19.x86_64
How do I know what package to install?
If you see your compiles are calling for files that you do not have then you can use repoquery
to find out what package(s) provide various files like so:
$ repoquery -f '*/libdb-5.3.so'
libdb-0:5.3.21-11.fc19.x86_64
libdb-0:5.3.21-11.fc19.i686
Related videos on Youtube
domaniqs
Updated on September 18, 2022Comments
-
domaniqs over 1 year
I am trying to compile iproute2-3-12-0 on Fedora 19, I have BerkeleyDB installed, the command
ls -la /usr/lib/libdb*
gives following results:-rwxr-xr-x 1 root root 1847852 May 16 2013 /usr/lib/libdb-5.3.so lrwxrwxrwx 1 root root 12 Sep 18 20:15 /usr/lib/libdb-5.so -> libdb-5.3.so lrwxrwxrwx 1 root root 18 Jan 4 12:57 /usr/lib/libdbus-1.so.3 -> libdbus-1.so.3.7.4 -rwxr-xr-x 1 root root 317720 Nov 11 19:24 /usr/lib/libdbus-1.so.3.7.4
I have newest version of Bison and Flex. I use kernel: 3.12.8-200.fc19.x86_64. I have ldb in
/usr/lib and /usr/lib64
. I did not find anyLDFLAGS
inMakefile
though.I get an error:
ssfilter.y: conflicts: 27 shift/reduce /usr/bin/ld: cannot find -ldb collect2: error: ld returned 1 exit status make[1]: *** [arpd] Error 1 make: *** [all] Error 2
A closer look at the end of make log reveals:
make[1]: Entering directory `/root/Traffic_Shaping/iproute2-3.12.0/bridge' gcc -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wold-style-definition -O2 -I../include -DRESOLVE_HOSTNAMES -DLIBDIR=\"/usr/lib64\" -DCONFDIR=\"/etc/iproute2\" -D_GNU_SOURCE -c -o bridge.o bridge.c gcc -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wold-style-definition -O2 -I../include -DRESOLVE_HOSTNAMES -DLIBDIR=\"/usr/lib64\" -DCONFDIR=\"/etc/iproute2\" -D_GNU_SOURCE -c -o fdb.o fdb.c gcc -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wold-style-definition -O2 -I../include -DRESOLVE_HOSTNAMES -DLIBDIR=\"/usr/lib64\" -DCONFDIR=\"/etc/iproute2\" -D_GNU_SOURCE -c -o monitor.o monitor.c gcc -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wold-style-definition -O2 -I../include -DRESOLVE_HOSTNAMES -DLIBDIR=\"/usr/lib64\" -DCONFDIR=\"/etc/iproute2\" -D_GNU_SOURCE -c -o link.o link.c gcc -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wold-style-definition -O2 -I../include -DRESOLVE_HOSTNAMES -DLIBDIR=\"/usr/lib64\" -DCONFDIR=\"/etc/iproute2\" -D_GNU_SOURCE -c -o mdb.o mdb.c gcc -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wold-style-definition -O2 -I../include -DRESOLVE_HOSTNAMES -DLIBDIR=\"/usr/lib64\" -DCONFDIR=\"/etc/iproute2\" -D_GNU_SOURCE -c -o vlan.o vlan.c gcc bridge.o fdb.o monitor.o link.o mdb.o vlan.o ../lib/libnetlink.a ../lib/libutil.a ../lib/libnetlink.a ../lib/libutil.a -o bridge make[1]: Leaving directory `/root/Traffic_Shaping/iproute2-3.12.0/bridge' make[1]: Entering directory `/root/Traffic_Shaping/iproute2-3.12.0/misc' gcc -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wold-style-definition -O2 -I../include -DRESOLVE_HOSTNAMES -DLIBDIR=\"/usr/lib64\" -DCONFDIR=\"/etc/iproute2\" -D_GNU_SOURCE -c -o ss.o ss.c bison ssfilter.y -o ssfilter.c ssfilter.y: conflicts: 27 shift/reduce gcc -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wold-style-definition -O2 -I../include -DRESOLVE_HOSTNAMES -DLIBDIR=\"/usr/lib64\" -DCONFDIR=\"/etc/iproute2\" -D_GNU_SOURCE -c -o ssfilter.o ssfilter.c gcc ss.o ssfilter.o ../lib/libnetlink.a ../lib/libutil.a -o ss gcc -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wold-style-definition -O2 -I../include -DRESOLVE_HOSTNAMES -DLIBDIR=\"/usr/lib64\" -DCONFDIR=\"/etc/iproute2\" -D_GNU_SOURCE -o nstat nstat.c -lm gcc -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wold-style-definition -O2 -I../include -DRESOLVE_HOSTNAMES -DLIBDIR=\"/usr/lib64\" -DCONFDIR=\"/etc/iproute2\" -D_GNU_SOURCE -o ifstat ifstat.c ../lib/libnetlink.a ../lib/libutil.a -lm gcc -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wold-style-definition -O2 -I../include -DRESOLVE_HOSTNAMES -DLIBDIR=\"/usr/lib64\" -DCONFDIR=\"/etc/iproute2\" -D_GNU_SOURCE -o rtacct rtacct.c ../lib/libnetlink.a ../lib/libutil.a -lm gcc -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wold-style-definition -O2 -I../include -DRESOLVE_HOSTNAMES -DLIBDIR=\"/usr/lib64\" -DCONFDIR=\"/etc/iproute2\" -D_GNU_SOURCE -I/usr/include/libdb4 -o arpd arpd.c ../lib/libnetlink.a ../lib/libutil.a -ldb -lpthread /usr/bin/ld: cannot find -ldb collect2: error: ld returned 1 exit status make[1]: *** [arpd] Error 1 make[1]: Leaving directory `/root/Traffic_Shaping/iproute2-3.12.0/misc' make: *** [all] Error 2
How can I get
ld
to findlibdb
?-
Martin von Wittich over 10 yearsFirst Google result says: you need to have the appropriate
-dev
package forlibdb-5.3.so
installed. As I'm not using Fedora, you'll have to figure out the correct package name yourself unfortunately. -
Martin von Wittich over 10 years
-
Admin over 10 yearsyour libs are in
/usr/lib
and you compile with/usr/lib64
, why? -
domaniqs over 10 years@martin-von-wittich Bingo! Many thanks for help!
-
-
domaniqs over 10 yearsThank you for explaining that to me! Now I can clearly see that I've been missing bits and pieces. Installation of libdb-devel did the job! Best Regards
-
slm over 10 years@domaniqs - great news!
-
vonbrand over 10 yearsThe
-devel
packages contain whatever is needed to develop against the library. This includes header (include
) files, but also shared and static libraries for linking, and sometimes special build tools or configuration.