the-tcpdump-group / tcpslice

tcpslice concatenates multiple pcap files together, or extracts time slices from one or more pcap files.
65 stars 22 forks source link

fails to build on Solaris with GCC when libnids is present #31

Open infrastation opened 2 weeks ago

infrastation commented 2 weeks ago

Sun C does not detect libnids, thus does not trigger this problem.

===== SETUP 4: CC=gcc BUILD_LIBPCAP=no =====
Use system libpcap
rm -f pcap-bpf.o fad-getad.o  pcap-dbus.o pcap-rdmasniff.o  pcap.o gencode.o optimize.o nametoaddr.o etherent.o  fmtutils.o pcap-util.o  savefile.o sf-pcap.o sf-pcapng.o pcap-common.o  bpf_image.o bpf_filter.o bpf_dump.o  scanner.o grammar.o  libpcap.a libpcap.so.`cat ./VERSION`  libpcap-`cat ./VERSION`.tar.gz scanner.c grammar.c scanner.h grammar.h  lex.yy.c pcap-config libpcap.pc libpcap.so config.h.in~ configure~ configure.ac~
(cd rpcapd; make clean)
rm -f daemon.o  fileconf.o  log.o  rpcapd.o rpcapd
(cd testprogs; make clean)
rm -f  activatetest  can_set_rfmon_test  capturetest  filtertest  findalldevstest-perf  findalldevstest  opentest  nonblocktest  reactivatetest  selpolltest  threadsignaltest  writecaptest
rm -rf *.dSYM
rm -f Makefile grammar.y config.cache config.log config.status \
    config.h os-proto.h libpcap.pc pcap-config stamp-h stamp-h.in
rm -f pcap.3pcap  pcap_compile.3pcap  pcap_datalink.3pcap  pcap_dump_open.3pcap  pcap_get_tstamp_precision.3pcap  pcap_list_datalinks.3pcap  pcap_list_tstamp_types.3pcap  pcap_open_dead.3pcap  pcap_open_offline.3pcap  pcap_set_immediate_mode.3pcap  pcap_set_tstamp_precision.3pcap  pcap_set_tstamp_type.3pcap cbpf-savefile.manfile  pcap-savefile.manfile pcap-filter.manmisc  pcap-linktype.manmisc  pcap-tstamp.manmisc
rm -rf autom4te.cache
(cd rpcapd; make distclean)
rm -f daemon.o  fileconf.o  log.o  rpcapd.o rpcapd
rm -f Makefile config.cache config.log config.status \
    config.h stamp-h stamp-h.in
rm -f rpcapd.manadmin rpcapd-config.manfile
rm -rf autom4te.cache
(cd testprogs; make distclean)
rm -f  activatetest  can_set_rfmon_test  capturetest  filtertest  findalldevstest-perf  findalldevstest  opentest  nonblocktest  reactivatetest  selpolltest  threadsignaltest  writecaptest
rm -rf *.dSYM
rm -f Makefile config.cache config.log config.status \
    config.h stamp-h stamp-h.in
rm -rf autom4te.cache
$ ./build.sh
gcc (GCC) 5.5.0
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Compiler identification: gcc-5.5.0
$ ./autogen.sh
autoreconf identification: 2.69
$ ./configure --prefix=/tmp/tcpslice_build_matrix.XXQJwsWa
checking build system type... sparc-sun-solaris2.11
checking host system type... sparc-sun-solaris2.11
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for gcc option to accept ISO C99... none needed
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /usr/bin/ggrep
checking for egrep... /usr/bin/ggrep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking size of void *... 4
checking size of time_t... 4
checking for special C compiler options needed for large files... no
checking for _FILE_OFFSET_BITS value needed for large files... 64
checking for _LARGEFILE_SOURCE value needed for large files... no
checking for posix_fadvise... yes
checking whether to look for a local libpcap... yes
checking for local pcap library... not found
checking for pkg-config... /usr/bin/pkg-config
checking whether there are .pc files for libpcap... no
checking for pcap-config... /usr/bin/pcap-config
checking size of void *... (cached) 4
checking for pcap_loop... yes
checking whether to enable the instrument functions code... no
checking for nids_pcap_handler in -lnids... yes
checking for osip_message_parse in -losipparser2... no
configure: WARNING: Libosip2 not present or too old; tcpslice won't be able to track SIP calls!
configure: WARNING: Get the latest version of Libosip at https://www.gnu.org/software/osip/
checking for asn1PD_H225RasMessage in -looh323c... no
configure: WARNING: Libooh323c not present or too old; tcpslice won't be able to track H.323 calls!
configure: WARNING: Get the latest version of Libooh323c at https://sourceforge.net/projects/ooh323c/
checking pcap/pcap-inttypes.h usability... yes
checking pcap/pcap-inttypes.h presence... yes
checking for pcap/pcap-inttypes.h... yes
checking for pcap_lib_version... yes
checking for u_int8_t... no
checking for u_int16_t... no
checking for u_int32_t... no
checking for u_int64_t... no
checking whether the compiler supports the -W option... yes
checking whether the compiler supports the -Wall option... yes
checking whether the compiler supports the -Wassign-enum option... no
checking whether the compiler supports the -Wcast-qual option... yes
checking whether the compiler supports the -Wmissing-prototypes option... yes
checking whether the compiler supports the -Wmissing-variable-declarations option... no
checking whether the compiler supports the -Wnull-pointer-subtraction option... no
checking whether the compiler supports the -Wold-style-definition option... yes
checking whether the compiler supports the -Wpedantic option... yes
checking whether the compiler supports the -Wpointer-arith option... yes
checking whether the compiler supports the -Wpointer-sign option... yes
checking whether the compiler supports the -Wshadow option... yes
checking whether the compiler supports the -Wsign-compare option... yes
checking whether the compiler supports the -Wstrict-prototypes option... yes
checking whether the compiler supports the -Wundef option... yes
checking whether the compiler supports the -Wunreachable-code-return option... no
checking whether the compiler supports the -Wunused-but-set-parameter option... yes
checking whether the compiler supports the -Wunused-but-set-variable option... yes
checking whether the compiler supports the -Wused-but-marked-unused option... no
checking whether the compiler supports the -Wwrite-strings option... yes
checking whether the compiler supports generating dependencies... yes, with -M
checking whether to use an os-proto.h header... no
checking for a BSD-compatible install... /usr/bin/ginstall -c
configure: creating ./config.status
config.status: creating Makefile
config.status: creating config.h
config.status: executing .devel commands
./mkdep -c gcc -m "-M" -s "." -DHAVE_CONFIG_H -I. -I/usr/include tcpslice.c gmt2local.c gwtm2secs.c search.c  seek-tell.c sessions.c util.c
$ make -s clean
$ make -s CFLAGS=-Werror
Undefined                       first referenced
 symbol                             in file
inet_ntoa                           sessions.o  (symbol belongs to implicit dependency /usr/lib/libnsl.so.1)
ld: fatal: symbol referencing errors
*** Error code 1
The following command caused the error:
gcc -W -Wall -Wcast-qual -Wmissing-prototypes -Wold-style-definition -Wpedantic -Wpointer-arith -Wpointer-sign -Wshadow -Wsign-compare -Wstrict-prototypes -Wundef -Wunused-but-set-parameter -Wunused-but-set-variable -Wwrite-strings -DHAVE_CONFIG_H -I. -I/usr/include -Werror  -o tcpslice tcpslice.o gmt2local.o gwtm2secs.o search.o  seek-tell.o sessions.o util.o   -lnids -L/usr/lib  -lpcap
make: Fatal error: Command failed for target `tcpslice'
denis@gcc-solaris11:~/gitrepos/tcpslice$ git grep inet_ntoa
sessions.c:       inet_ntoa(*((struct in_addr *)&first_session->addr.saddr)),
sessions.c:       inet_ntoa(*((struct in_addr *)&first_session->addr.daddr)),

$ gcc --version
gcc (GCC) 5.5.0
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ uname -a
SunOS gcc-solaris11 5.11 11.3 sun4u sparc SUNW,SPARC-Enterprise

The cause of this is lack of -lsocket -lnsl, which is probably due to lack of equivalent of AC_LBL_LIBRARY_NET in tcpdump. However, the source needs inet_ntoa() only when libnids is present, so it seems the macro would need to be used conditionally.

infrastation commented 2 weeks ago

Reproduced on cfarm211.cfarm.net.