The GNU linker use the firt match, shared and then static, in the directory it searches for -lfoo. That means the shared and static libraries for the linker have to be in the same directory. But for db3, it has /usr/lib/libdb-3.1.a /usr/lib/libdb-3.1.la in db3-devel and /lib/libdb-3.1.so in db3. For gcc 2.96, # gcc .... -ldb-3.1 will pickup /usr/lib/libdb-3.1.a as /usr/lib/gcc-lib/i386-redhat-linux/2.96/../../../libdb-3.1.a since /usr/lib/gcc-lib/i386-redhat-linux/2.96/../../.. is searched before /lib. There are many shared libraries like that under /lib. They all should be fixed.
Fixed by adding ln -s ../../lib/libdb-3.1.so /usr/lib/libdb-3.1.so add not editing the "libdir='...'" line in libdb-3.1.la