Last Updated: February 25, 2016
·
1.748K
· jenrzzz

Installing iftop from homebrew on OS X

I was having trouble getting iftop to build with homebrew, and make was erroring out without any useful information.

brew: superenv removed: -g -O2
make[2]: *** [screenfilter.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2

After trying to compile manually, I was able to get the actual error from gcc, whining about a missing header.

screenfilter.c:14:19: error: regex.h: No such file or directory
screenfilter.c:23: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘preg’
screenfilter.c: In function ‘screen_filter_set’:
screenfilter.c:31: error: ‘preg’ undeclared (first use in this function)
screenfilter.c:31: error: (Each undeclared identifier is reported only once
screenfilter.c:31: error: for each function it appears in.)
screenfilter.c:34: error: ‘REG_ICASE’ undeclared (first use in this function)
screenfilter.c:34: error: ‘REG_EXTENDED’ undeclared (first use in this function)
screenfilter.c: In function ‘screen_filter_match’:
screenfilter.c:52: error: ‘preg’ undeclared (first use in this function)
make[2]: *** [screenfilter.o] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2

iftop is pretty damn old, and GNU regex has been rolled into glib since it was written. To give it the header file it was expecting, I grabbed the circa-1993 regex-0.12 tarball and dropped regex.h into /usr/local/include. Then I was able to brew and link iftop with no issues.