This little fix can be applied to any Gentoo installation, or any other distro by that matter where you’re given the possibility to compile or extract an rpm.

I’ve encountered the "/ld: cannot find -lgdbm" error while trying to "emerge amarok" in Gentoo. After searching the Internet with no conclusive results, I’ve found out that this may be a shared library error and because it was generated by the compiler, than GCC must have been the guilty guy.

Let’s get things organized. We will have to: update the portage tree, see if there is a GCC update, delete the old libgdbm libraries just to be sure, and emerge GCC and finally, selecting the new compiler.

[HappyFeet] / # emerge –sync
[HappyFeet] / # emerge -pvu gcc
[HappyFeet] / # ls /usr/lib/libgdbm*
/usr/lib/libgdbm.a
/usr/lib/libgdbm.so.3
/usr/lib/libgdbm_compat.la
/usr/lib/libgdbm_compat.so.3.0.0
/usr/lib/libgdbm.la
/usr/lib/libgdbm.so.3.0.0
/usr/lib/libgdbm_compat.so
/usr/lib/libgdbm.so
/usr/lib/libgdbm_compat.a
/usr/lib/libgdbm_compat.so.3
[HappyFeet] / # rm -v /usr/lib/libgdbm*
[HappyFeet] / # emerge -pv gcc
[HappyFeet] / # emerge -u gcc
[HappyFeet] / # eselect compiler list
[HappyFeet] / # eselect compiler set [number]

That’s all. I’ve chosen to update the compiler for obvious reasons mainly. You can just reinstall the old compiler, without harming anything. The above error happens usually when uninstalling a high number of packages and that’s exactly what I did.