Building Sendmail sample.c milter

The following instructions were used to build the sample.c milter included in $SENDMAIL_SRC/libmilter/README with gcc 3.2.2 on a Solaris 2.6 system. In this example, $SENDMAIL_SRC is sendmail-8.12.10.

1. Cut the sample milter source code from the $SENDMAIL_SRC/libmilter/README. The sample milter begins with "/* A trivial filter that logs all email to a file. */" and ends with "/* eof */". Save the file as $SENDMAIL_SRC/obj*/libmilter/sample.c.

2. Build libmilter.a
cd $SENDMAIL_SRC/libmilter

3. Compile the sample milter.
cd ../obj*/libmilter
gcc -I../../sendmail -I../../include -o sample sample.c libmilter.a ../libsm/libsm.a -lpthread -lsocket -lnsl -lresolv

Without specifying the include statements above, you may receive the following errors when attempting to compile the sample milter:

libmilter.a(listener.o): In function `mi_milteropen':
listener.o(.text+0x330): undefined reference to `getservbyname'
listener.o(.text+0x3ac): undefined reference to `inet_addr'
listener.o(.text+0x484): undefined reference to `socket'
listener.o(.text+0x530): undefined reference to `setsockopt'
listener.o(.text+0x570): undefined reference to `bind'
listener.o(.text+0x5b0): undefined reference to `listen'
libmilter.a(listener.o): In function `mi_listener':
listener.o(.text+0xb38): undefined reference to `accept'
listener.o(.text+0xca0): undefined reference to `setsockopt'
libmilter.a(sm_gethost.o): In function `mi_gethostbyname':
sm_gethost.o(.text+0x4): undefined reference to `gethostbyname'
libmilter.a(engine.o): In function `st_connectinfo':
engine.o(.text+0x9c4): undefined reference to `inet_aton'
collect2: ld returned 1 exit status

More information at Google Groups.

Back to
Last modified: 11/17/2003