[Iftop-users] iftop 0.17 On HP-UX 11.23

Franz, Jay Jay.Franz at ssa.gov
Mon, 27 Aug 2007 15:49:25 -0400


After much wailing and gnashing of teeth, I was able to successfully
compile iftop 0.17 on HP-UX 11.23 by adding both LDFLAGS and CPPFLAGS
definitions to the configure command and by patching two programs.  The
sordid details follow for any interested parties.

Jay Franz
jay.franz@ssa.gov

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D

First, my build environment:

autoconf-2.61
automake-1.10
binutils-2.17
bison-2.3
flex-2.5.33
gawk-3.1.5
gcc-4.1.2
gettext-0.16.1
libiconv-1.11
libpcap-0.9.7
libtool-1.5.24
m4-1.4.9
make-3.81
ncurses-5.6
patch-2.5.4
perl-5.8.8
sed-4.1.5
shtool-2.0.7
termcap-1.3.1
texinfo-4.9

Secondly, my configure statement:

# LDFLAGS=3D'-lpthread -lipv6' CPPFLAGS=3D'-I =
/usr/local/include/ncurses'
./configure

And, finally, two patches, one for 'addrs_dlpi.c.patch' and one for
'dlcommon.c.patch'.

addrs_dlpi.c.patch:

24d23
< #include <sys/sockio.h>
28a28
> #include <netinet/in.h>

dlcommon.c.patch:

28a29
> #include      <stdlib.h>
465c466
< static void
---
> void

--------------------

An explanation of the above.

First, the build environment should be self-explanatory. the gcc,
gettext, libiconv, and make packages were downloaded and installed from
the Porting and Archiving Center for HP-UX
(http://hpux.connect.org.uk/).  All others were built on the target
server.

----------

Secondly, the first LDFLAG, '-lpthread', addresses the failure of the
configure script to accurately identify the threads capability in HP-UX
11.23.  Running configure without the flag results in the following
error:

# ./configure
<snip>
checking POSIX threads compilation... CFLAGS=3D and LIBS=3D
checking POSIX threads usability... configure: error: it fails.  We
probably guessed the wrong CFLAGS.

I can provide the 'config.log' for anyone who wants it.

----------

The second LDFLAG, '-lipv6', addresses the error when linking all of the
compiled programs:

gcc  -g -O2   -lpthread -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  -lcurses=20
ld: Unsatisfied symbol "if_nameindex" in file options.o
ld: Unsatisfied symbol "if_freenameindex" in file options.o
2 errors.
collect2: ld returned 1 exit status

The 'if_nameindex' and 'if_freenameindex' symbols are defined in the
'ipv6' library.

----------

The CPPFLAG, '-I /usr/local/include/ncurses', addresses the following
compilation error when compiling 'edline.c':

source=3D'edline.c' object=3D'edline.o' libtool=3Dno \
        depfile=3D'.deps/edline.Po' tmpdepfile=3D'.deps/edline.TPo' \
        depmode=3Dgcc3 /bin/sh ./config/depcomp \
        gcc -DHAVE_CONFIG_H -I. -I. -I.     -g -O2  -c `test -f
'edline.c' || echo './'`edline.c
edline.c: In function 'edline':
edline.c:68: error: 'KEY_END' undeclared (first use in this function)
edline.c:68: error: (Each undeclared identifier is reported only once
edline.c:68: error: for each function it appears in.)
make[2]: *** [edline.o] Error 1
make[2]: Leaving directory `/usr/local/install/iftop-0.17'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/usr/local/install/iftop-0.17'
make: *** [all] Error 2

It is possible that this could be addressed in the configure script,
since it appears to correctly identify the native 'curses' library;
however, 'gcc' fails to locate the native library and forcing its
inclusion (i.e., -I /usr/include) has no effect.

----------

Thirdly, the first patch, for 'addrs_dlpi.c' addresses the following
compilation errors:

source=3D'addrs_dlpi.c' object=3D'addrs_dlpi.o' libtool=3Dno \
        depfile=3D'.deps/addrs_dlpi.Po' =
tmpdepfile=3D'.deps/addrs_dlpi.TPo'
\
        depmode=3Dgcc3 /bin/sh ./config/depcomp \
        gcc -DHAVE_CONFIG_H -I. -I. -I.   -I /usr/local/include/ncurses
-g -O2  -c `test -f 'addrs_dlpi.c' || echo './'`addrs_dlpi.c
addrs_dlpi.c:24:24: error: sys/sockio.h: No such file or directory
addrs_dlpi.c:53: warning: 'struct in_addr' declared inside parameter
list
addrs_dlpi.c:53: warning: its scope is only this definition or
declaration, which is probably not what you want
addrs_dlpi.c: In function 'get_addrs_dlpi':
addrs_dlpi.c:184: error: dereferencing pointer to incomplete type
addrs_dlpi.c:190: error: dereferencing pointer to incomplete type
addrs_dlpi.c:190: error: invalid application of 'sizeof' to incomplete
type 'struct in_addr'=20
make[2]: *** [addrs_dlpi.o] Error 1
make[2]: Leaving directory `/usr/local/install/iftop-0.17'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/usr/local/install/iftop-0.17'
make: *** [all] Error 2

The first error, regarding the 'sys/sockio.h' header file, is resolved
by removing the include statement, as this file does not exist on HP-UX
11.23.  The other errors, regarding the 'in_addr' structure, are
resolved by including the 'netinet/in.h' library, where it is defined
for HP-UX 11.23.

----------

The second patch, for 'dlcommon.c', resolves the following compilation
errors and warnings:

source=3D'dlcommon.c' object=3D'dlcommon.o' libtool=3Dno \
        depfile=3D'.deps/dlcommon.Po' tmpdepfile=3D'.deps/dlcommon.TPo' =
\
        depmode=3Dgcc3 /bin/sh ./config/depcomp \
        gcc -DHAVE_CONFIG_H -I. -I. -I.   -I /usr/local/include/ncurses
-g -O2  -c `test -f 'dlcommon.c' || echo './'`dlcommon.c
dlcommon.c:467: error: static declaration of 'sigalrm' follows
non-static declaration
dlcommon.h:35: error: previous declaration of 'sigalrm' was here
dlcommon.c: In function 'expecting':
dlcommon.c:531: warning: incompatible implicit declaration of built-in
function 'exit'
dlcommon.c: In function 'err':
dlcommon.c:1333: warning: incompatible implicit declaration of built-in
function 'exit'
dlcommon.c: In function 'syserr':
dlcommon.c:1340: warning: incompatible implicit declaration of built-in
function 'exit'
make[2]: *** [dlcommon.o] Error 1
make[2]: Leaving directory `/usr/local/install/iftop-0.17'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/usr/local/install/iftop-0.17'
make: *** [all] Error 2

The errors, regarding re-declaration of the 'sigalrm' function, are
resolved by removing the 'static' statement from the re-declaration of
the function.  This does allow the 'dlcommon.c' program to compile
cleanly and the resulting build of iftop appears to work as expected;
however, I am not a C programmer and this may not have been what was
originally intended.  YMMV.  The warnings, regarding the 'exit'
function, are resolved by including the 'stdlib.h' header file.

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D