Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 any LDFLAGS in Makefile 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 find libdb?

share|improve this question
First Google result says: you need to have the appropriate -dev package for libdb-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 Jan 27 '14 at 22:41
Possibly libdb-devel? – Martin von Wittich Jan 27 '14 at 22:42
your libs are in /usr/lib and you compile with /usr/lib64, why? – user55518 Jan 27 '14 at 22:51
@martin-von-wittich Bingo! Many thanks for help! – domaniqs Jan 28 '14 at 9:30
up vote 3 down vote accepted

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.


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 

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
$ rpm -qf /usr/lib64/libdb-5.3.so

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'
share|improve this answer
Thank 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 – domaniqs Jan 28 '14 at 9:32
@domaniqs - great news! – slm Jan 28 '14 at 9:34
The -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. – vonbrand Jan 30 '14 at 14:14

lib will contain 32bit libraries, and lib64 64bit. I would assume your gcc is generating 64bit binaries. So /lib64 (/usr/lib64) needs to have the correct db libraries. You can run the gcc command manually with --verbose to see everything it's doing. (i.e. the ld command it's running)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.