[Iftop-users] iftop-0.16 on NetBSD

Chris Lightfoot chris at ex-parrot.com
Sat, 26 Jun 2004 13:01:55 +0100


On Wed, Jun 23, 2004 at 11:48:23AM +0100, Chris Lightfoot wrote:
> On Tue, Jun 22, 2004 at 05:21:14PM -0500, John Thompson wrote:
> > Several weeks ago I posted about a problem configuring iftop to compile
> > on NetBSD-1.6.1; specifically, the configure script would die when it
> > came to checking for Posix thread support.  I've now updated that
> > machine to NetBSD-1.6.2 and the configure script runs to completion
> > without complaint (after passing it LDFLAGS=-L/usr/pkg/lib/ and
> > CPPFLAGS=-I/usr/pkg/include to point it to the Posix thread support). 
> > Unfortunately, it fails during the compile:
> 
> this looks like two separate issues:
> 
> > gcc  -g -O2  -L/usr/pkg/lib/ -o iftop  addr_hash.o edline.o hash.o  iftop.o ns_hash.o options.o  resolver.o screenfilter.o serv_hash.o  sorted_list.o threadprof.o ui.o  util.o addrs_ioctl.o addrs_dlpi.o  dlcommon.o stringmap.o cfgfile.o  vector.o  -lpcap -lm  -lncurses -lpthread
> > ui.o: In function `draw_bar_scale':
> > /tmp/iftop-0.16/ui.c:269: undefined reference to `_acs_char'
> > /tmp/iftop-0.16/ui.c:281: undefined reference to `_acs_char'
> 
> This is a curses thing (referenced through mvaddch, which
> is presumably a macro); it really should Just Work.
> 
> Ah. Does NetBSD have an old-style curses as well as
> ncurses? If so, is it possible that the old curses header
> file is that being included as <curses.h>?

-- this turns out to be the problem here. If
    #include <curses.h>
in ui.c is changed to,
    #include <ncurses.h>
this works.

> > ui.o: In function `ui_loop':
> > /tmp/iftop-0.16/ui.c:1055: undefined reference to `__error'
> 
> that line reads,
> 
>     errno = 0;

This one is much uglier. On that particular machine,
/usr/pkg/include/errno.h defines,

    extern int *__error();
    #define errno (*__error())

which is a fairly standard way to make the errno interface
threads-compatible. However, the POSIX threads library on
that machine doesn't actually export the __error symbol.
It does export __errno, which references on the web
suggest has the same function. Manually forcing iftop to
use __errno result in a successful compile, but the
program segfaults on startup, which it obviously
shouldn't. So this guess at a solution is no good.

Unfortunately I can't find any libraries in /usr/pkg/lib
on that machine which define __error. So I don't know what
to do about this one. Any thoughts from other NetBSD
users?

(BTW-- it looks like there's an iftop port in NetBSD, but
perhaps this is only for more recent versions of the whole
operating system.)

-- 
``Be careful about reading health books. You may die of a misprint.''
  (Mark Twain)