Clearly it finds the correct include path (-ldb-4.2) and the correct function name (db_create_4002) but unfortunately it still attempts to use db_create (which is in the include path of sys-libs/db:4.5). I've fixed it locally by using sys-libs/db:4.5 but I guess it's supposed to be able to use db_create_4002 instead... As a side-note the elog in postinst() points to /usr/share/doc/${P}/${PN}-gentoo.readme.gz which is incorrect. Instead it should be /usr/share/doc/${PF}/${PN}-gentoo.readme* ($PF and may be any sort of compression..). # emerge -va1 courier-imap [...] [ebuild U ] net-mail/courier-imap-4.1.2-r1 [4.0.6-r2] USE="berkdb fam nls -debug -gdbm -ipv6 (-selinux)" 0 kB [...] checking for db_create_4004 in -ldb-4.4... no checking for db_create_4003 in -ldb-4.4... no checking for db_create_4002 in -ldb-4.4... no checking for db_create_4001 in -ldb-4.4... no checking for db_create_4000 in -ldb-4.4... no checking for db_create in -ldb-4.4... no checking for db_create_4004 in -ldb4.4... no checking for db_create_4003 in -ldb4.4... no checking for db_create_4002 in -ldb4.4... no checking for db_create_4001 in -ldb4.4... no checking for db_create_4000 in -ldb4.4... no checking for db_create in -ldb4.4... no checking for db_create_4004 in -ldb44... no checking for db_create_4003 in -ldb44... no checking for db_create_4002 in -ldb44... no checking for db_create_4001 in -ldb44... no checking for db_create_4000 in -ldb44... no checking for db_create in -ldb44... no checking for db_create_4004 in -ldb-4.3... no checking for db_create_4003 in -ldb-4.3... no checking for db_create_4002 in -ldb-4.3... no checking for db_create_4001 in -ldb-4.3... no checking for db_create_4000 in -ldb-4.3... no checking for db_create in -ldb-4.3... no checking for db_create_4004 in -ldb4.3... no checking for db_create_4003 in -ldb4.3... no checking for db_create_4002 in -ldb4.3... no checking for db_create_4001 in -ldb4.3... no checking for db_create_4000 in -ldb4.3... no checking for db_create in -ldb4.3... no checking for db_create_4004 in -ldb43... no checking for db_create_4003 in -ldb43... no checking for db_create_4002 in -ldb43... no checking for db_create_4001 in -ldb43... no checking for db_create_4000 in -ldb43... no checking for db_create in -ldb43... no checking for db_create_4004 in -ldb-4.2... no checking for db_create_4003 in -ldb-4.2... no checking for db_create_4002 in -ldb-4.2... yes checking for db_create_4004... no checking for db_create_4003... no checking for db_create_4002... yes checking for db_create_4001... no checking for db_create_4000... no checking for db_create... no [...] creating libbdbobj.la (cd .libs && rm -f libbdbobj.la && ln -s ../libbdbobj.la libbdbobj.la) /bin/sh ./libtool --tag=CXX --mode=link x86_64-pc-linux-gnu-g++ -march=k8 -pipe -O2 -ggdb -static -o testbdb testbdb.o libbdbobj.la -ldb-4.2 x86_64-pc-linux-gnu-g++ -march=k8 -pipe -O2 -ggdb -o testbdb testbdb.o ./.libs/libbdbobj.a /usr/lib64/libdb-4.2.so ./.libs/libbdbobj.a(bdbobj.o): In function `bdbobj_open': /var/tmp/portage/net-mail/courier-imap-4.1.2-r1/work/courier-imap-4.1.2/bdbobj/bdbobj.c:131: undefined reference to `db_create' collect2: ld returned 1 exit status make[3]: *** [testbdb] Error 1 make[3]: Leaving directory `/var/tmp/portage/net-mail/courier-imap-4.1.2-r1/work/courier-imap-4.1.2/bdbobj' make[2]: *** [all] Error 2 make[2]: Leaving directory `/var/tmp/portage/net-mail/courier-imap-4.1.2-r1/work/courier-imap-4.1.2/bdbobj' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory `/var/tmp/portage/net-mail/courier-imap-4.1.2-r1/work/courier-imap-4.1.2' make: *** [all] Error 2 * * ERROR: net-mail/courier-imap-4.1.2-r1 failed. * Call stack: * ebuild.sh, line 1654: Called dyn_compile * ebuild.sh, line 990: Called qa_call 'src_compile' * ebuild.sh, line 44: Called src_compile * courier-imap-4.1.2-r1.ebuild, line 165: Called die * * emake failed # eix -e sys-libs/db -c [I] sys-libs/db (4.2.52_p4-r2(4.2)@01/09/07 4.5.20_p2(4.5)@01/09/07): Oracle Berkeley DB # emerge --info Portage 2.1.3.7 (default-linux/amd64/2006.1/server, gcc-4.1.2, glibc-2.5-r4, 2.6.20-gentoo-r7 x86_64) ================================================================= System uname: 2.6.20-gentoo-r7 x86_64 AMD Sempron(tm) Processor 2800+ Gentoo Base System release 1.12.9 Timestamp of tree: Fri, 31 Aug 2007 22:00:01 +0000 distcc 2.18.3 x86_64-pc-linux-gnu (protocols 1 and 2) (default port 3632) [disabled] ccache version 2.4 [enabled] app-shells/bash: 3.2_p17 dev-lang/python: 2.4.4-r4 dev-python/pycrypto: 2.0.1-r6 dev-util/ccache: 2.4-r7 sys-apps/baselayout: 1.12.9-r2 sys-apps/sandbox: 1.2.17 sys-devel/autoconf: 2.13, 2.61 sys-devel/automake: 1.4_p6, 1.5, 1.6.3, 1.7.9-r1, 1.8.5-r3, 1.9.6-r2, 1.10 sys-devel/binutils: 2.17 sys-devel/gcc-config: 1.3.16 sys-devel/libtool: 1.5.24 virtual/os-headers: 2.6.17-r2 ACCEPT_KEYWORDS="amd64" CBUILD="x86_64-pc-linux-gnu" CFLAGS="-march=k8 -pipe -O2 -ggdb" CHOST="x86_64-pc-linux-gnu" CONFIG_PROTECT="/etc /lib/modules /usr/kde/3.5/env /usr/kde/3.5/share/config /usr/kde/3.5/shutdown /usr/share/X11/xkb /usr/share/config" CONFIG_PROTECT_MASK="/etc/env.d /etc/gconf /etc/php/apache2-php5/ext-active/ /etc/php/cgi-php5/ext-active/ /etc/php/cli-php5/ext-active/ /etc/revdep-rebuild /etc/terminfo /etc/texmf/web2c" CXXFLAGS="-march=k8 -pipe -O2 -ggdb" DISTDIR="/var/cache/paludis/distfiles" FEATURES="buildpkg ccache collision-protect distlocks fixpackages metadata-transfer parallel-fetch sandbox sfperms splitdebug strict test unmerge-orphans userfetch userpriv" GENTOO_MIRRORS="ftp://10.0.0.3 http://mirror.uni-c.dk/pub/gentoo http://ftp.belnet.be/mirror/rsync.gentoo.org/gentoo" LC_ALL="en_GB.UTF-8" MAKEOPTS="-j2" PKGDIR="/var/packages" PORTAGE_RSYNC_EXTRA_OPTS="--timeout=60 --exclude=/.cache" PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --delete-after --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --filter=H_**/files/digest-*" PORTAGE_TMPDIR="/var/tmp" PORTDIR="/var/repositories/gentoo" PORTDIR_OVERLAY="/var/repositories/local" SYNC="rsync://rsync.gentoo.org/gentoo-portage" USE="acpi alsa amd64 apache2 authdaemond bash-completion berkdb bitmap-fonts branding bzip2 cli cracklib crypt cups directfb dri dvb fam fbcon fortran gnutls gpm iconv imap isdnlog jpeg libwww lirc lm_sensors maildir mailwrapper midi mudflap mysql mythtv ncurses nls nptl nptlonly ntfs openmp pam pcre pdf perl pic png ppds pppd python readline reflection reiser4 reiserfs samba sasl session slp snmp spl ssl sysfs syslog tcpd test truetype truetype-fonts type1-fonts unichrome unicode usb vhosts vim vim-syntax vorbis xml xorg zlib" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mulaw multi null plug rate route share shm softvol" ELIBC="glibc" INPUT_DEVICES="evdev keyboard mouse" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIRC_DEVICES="hauppauge" USERLAND="GNU" VIDEO_CARDS="dummy fbdev v4l vesa vga via" Unset: CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LANG, LDFLAGS, LINGUAS, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS
Experienced the same issue while having sys-libs/db-4.2.52_p4-r2 and sys-libs/db-4.5.20_p2 installed. Unmerging the db-4.2 version solved the problem.
chutzpah has taken over courier-imap maint.
4.5.0 picks the correct db version and compiles fine in this testcase (both db 4.2 and 4.5 installed), so FIXED with this version :)