Add to Favourites Add to Favourites    Print this Article Print this Article

How to compile exim from source

In this how-to, we'll outline how to install a fresh exim binary for your system.

First, ensure you have the dependencies for exim.

apt-get install libdb-dev libperl-dev libsasl2-dev


yum install db4-devel cyrus-sasl-devel perl-ExtUtils-Embed


pkg_add -r cyrus-sasl2

The simplest method is to use custombuild:

cd /usr/local/directadmin/custombuild
./build update
./build set exim yes
./build exim

Restart exim, and you're done.

See below for possible errors and solutions.

If you want more control, instead of using custmbuild,you can do a manual compile.
We'll use exim 4.80.1 for this example.  Change all occurances of 4.80.1 to the version you want to use.

tar xvzf exim-4.80.1.tar.gz
cd exim-4.80.1/Local
perl -pi -e 's/^EXTRALIBS/#EXTRALIBS/' Makefile
perl -pi -e 's/HAVE_ICONV=yes/HAVE_ICONV=no/' Makefile
cd ..
make install

This will give you a new /usr/sbin/exim-4.76-1 binary which won't be what you want.. you'll need to rename it to /usr/sbin/exim:

cp -f /usr/sbin/exim-4.80.1-1 /usr/sbin/exim
chmod 4755 /usr/sbin/exim

Remember to restart exim after you're finished.

**Note: If you can't download the exim-4.76.tar.gz from the above link, just go to and find a different link there.  It's the original source, unmodified by us, you can get it anywhere.

You may need to edit the Local/Makefile and remove the iconv section near the top:  HAVE_ICONV=no
if you see this error

rfc2047.o: In function `rfc2047_decode2':
rfc2047.c:(.text+0x395): undefined reference to `libiconv_open'
rfc2047.c:(.text+0x45a): undefined reference to `libiconv'
rfc2047.c:(.text+0x539): undefined reference to `libiconv_close'

If you get perl errors during the compile, you may need to edit the Local/Makefile, and set the values for:

You can generate the values for those options with the following code:

echo "PERL_CC=`/usr/bin/perl -MConfig -e 'print $Config{cc}'`";
echo "PERL_CCOPTS=`/usr/bin/perl -MExtUtils::Embed -e ccopts`";
echo "PERL_LIBS=`/usr/bin/perl -MExtUtils::Embed -e ldopts`"

Sample values for FreeBSD 7:

PERL_CCOPTS= -DAPPLLIB_EXP="/usr/local/lib/perl5/5.8.8/BSDPAN" -DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/usr/local/include  -I/usr/local/lib/perl5/5.8.8/mach/CORE
PERL_LIBS=  -Wl,-R/usr/local/lib/perl5/5.8.8/mach/CORE  -Wl,-E -L/usr/local/lib /usr/local/lib/perl5/5.8.8/mach/auto/DynaLoader/DynaLoader.a -L/usr/local/lib/perl5/5.8.8/mach/CORE -lperl -lm -lcrypt -lutil

Sample values for Debian 4:

PERL_CCOPTS= -D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -DDEBIAN -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64  -I/usr/lib/perl/5.8/CORE
PERL_LIBS=-Wl,-E  -L/usr/local/lib /usr/lib/perl/5.8/auto/DynaLoader/DynaLoader.a -L/usr/lib/perl/5.8/CORE -ldl -lm -lpthread -lc -lcrypt

On debian, if you're missing any requird modules, without actually installing "exim4", you can use:

apt-get build-dep exim4

to install all dependancies that exim needs to compile, without installing the apt-get version of exim itself.

Debian 5 requires the libperl5.10 module. If you don't have it:

apt-get install libperl5.10

The above code will resolve the error:

exim: error while loading shared libraries: cannot open shared object file: No such file or directory

Debian 7

apt-get install libdb5.1-dev libperl-dev libsasl2-dev

Was this answer helpful?

Also Read