I needed to add some monitoring of one of my customer’s mail servers and compiled sysmon on a CentOS Linux machine to do the monitoring. When compiling sysmon I got the error message "undefined reference to `yywrap’". This post looks at the full error message and the solution.
How to install sysmon
The steps to install sysmon are as follows:
wget ftp://puck.nether.net/pub/jared/sysmon-0.92.2.tar.gz tar -zxf sysmon-0.92.2.tar.gz cd sysmon-0.92.2 ./configure cd src make sudo make install
The error message
At the "sudo make install" step I got the following error message and sysmon would not install:
/bin/rm -f sysmond core sysmond.core gcc -L/usr/local//lib -o sysmond heartbeat.o syswatch.o page.o tcp.o udp.o icmp.o pop3.o umichX500.o loadconfig.o smtp.o nntp.o talktcp.o imap.o lib.o textfile.o http.o srvclient.o dnscache.o ircd.o sysmon.o radius.o md5.o parser.o snpp.o snmp.o pingv6.o logging.o dns.o ssh.o -lwrap -lbsd -lresolv -lpthread -lnsl parser.o: In function `sysmon_conf_yylex': /home/chris/install/sysmon-0.92.2/src/parser.l:2212: undefined reference to `yywrap' collect2: ld returned 1 exit status make: *** [sysmond] Error 1
Read configure’s output better…
If I’d read the output from ./configure better I would have seen this in there:
... checking for flex... no checking for lex... no configure: WARNING: without lex or flex sysmon may not compile but give it a try ... configure: WARNING: We may not compile as we did not find yywrap. I suggest installing flex. ftp://ftp.gnu.org/gnu/non-gnu/flex/ ...
The solution
The solution to this error message when compiling sysmon is to ensure you have flex installed. On a CentOS machine do this:
sudo yum install flex
Debian, or a Debian derived distro such as Ubuntu, would do this:
sudo apt-get install flex
After flex has been installed, you’ll need to start over from ./configure – if you attempt to make clean, make, make install it will still error out because it still doesn’t know flex is there:
cd .. ./configure cd src make sudo make install
Conclusion
sysmon needs flex to compile. If it isn’t already installed you’ll get the error message detailed in this post. Install flex, then configure and make again.