Exim won't start - Error loading lookup module mysql.so

It turns out that it has nothing to do with the gcc version or optimization failures. Instead, it's an incomplete compile/link of the exim binary. There is a flag (-rdynamic) for gcc to tell the linker to export the symbols to be visible to dynamically loaded modules. This flag must be passed to gcc when building the mysql.so and when building the Exim binary.

If this RPM is based on a Fedora exim.spec file (mine was), I've found that there are patches that set the LFLAGS variable in Local/Makefile, but then the make command overrides LFLAGS on the commandline. Simply move whatever you are setting LFLAGS to into your Local/Makefile and remove it from the make command:

# This used to be set on the make commandline
echo 'LFLAGS+=-pie' >> Local/Makefile
#
# Then further down where the make command is,
# remove the LFLAGS= setting, leaving only:
make _lib=%{_lib} FULLECHO=

Othersie, it's likely that all you need is to add to the end of your Local/Makefile:

LFLAGS+=-rdynamic -ldl
# _OR_
EXTRALIBS_EXIM+=-rdynamic -ldl

More detail is available here: https://stackoverflow.com/a/482556/611911

Note: While you accepted the first answer I provided, all it really does is say "yeah, I had the problem too." This answer actually fixes the problem. :-)


Exim can't load mysql.so because it hasn't built. You have to ensure you have at least mysql-client installed properly.