prads icon indicating copy to clipboard operation
prads copied to clipboard

Cygwin compile error.

Open Anandir opened this issue 6 years ago • 10 comments

Hi everyone, I've tried to compile PRADS under a Cygwin environment for some tests using a Windows machine, but I've got this error:

$ make You need libpcre-dev and libpcap-dev to compile this program. make CONFDIR=/usr/local/etc/prads -C src/ make[1]: entering in the folder "/home/Giacomo/prads/src" cc -O3 -DRELEASE='"-20-g407cf7c"' -DCONFDIR='"/usr/local/etc/prads/"' -D__USE_GNU -c -o bstrlib.o bstrlib.c cc -O3 -DRELEASE='"-20-g407cf7c"' -DCONFDIR='"/usr/local/etc/prads/"' -D__USE_GNU -c -o sig_tcp.o sig_tcp.c sig_tcp.c: In function ‘grab_name’: sig_tcp.c:918:17: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers] if (!r || !(s = r->h_name) || !(j = strlen(s))) return ""; ^ cc -O3 -DRELEASE='"-20-g407cf7c"' -DCONFDIR='"/usr/local/etc/prads/"' -D__USE_GNU -c -o config.o config.c cc -O3 -DRELEASE='"-20-g407cf7c"' -DCONFDIR='"/usr/local/etc/prads/"' -D__USE_GNU -c -o sys_func.o sys_func.c cc -O3 -DRELEASE='"-20-g407cf7c"' -DCONFDIR='"/usr/local/etc/prads/"' -D__USE_GNU -c -o assets.o assets.c cc -O3 -DRELEASE='"-20-g407cf7c"' -DCONFDIR='"/usr/local/etc/prads/"' -D__USE_GNU -c -o prads.o prads.c prads.c:55:12: warning: ‘optind’ redeclared without dllimport attribute: previous dllimport ignored [-Wattributes] extern int optind, opterr, optopt; // getopt() ^~~~~~ prads.c:55:20: warning: ‘opterr’ redeclared without dllimport attribute: previous dllimport ignored [-Wattributes] extern int optind, opterr, optopt; // getopt() ^~~~~~ prads.c:55:28: warning: ‘optopt’ redeclared without dllimport attribute: previous dllimport ignored [-Wattributes] extern int optind, opterr, optopt; // getopt() ^~~~~~ cc -O3 -DRELEASE='"-20-g407cf7c"' -DCONFDIR='"/usr/local/etc/prads/"' -D__USE_GNU -c -o dhcp.o dhcp.c cc -O3 -DRELEASE='"-20-g407cf7c"' -DCONFDIR='"/usr/local/etc/prads/"' -D__USE_GNU -c -o dump_dns.o dump_dns.c cc -O3 -DRELEASE='"-20-g407cf7c"' -DCONFDIR='"/usr/local/etc/prads/"' -D__USE_GNU -c -o mac.o mac.c mac.c: In function ‘arp_check’: mac.c:335:6: warning: type of ‘eth_hdr’ defaults to ‘int’ [-Wimplicit-int] void arp_check(eth_hdr, tstamp) ^~~~~~~~~ mac.c:335:6: warning: type of ‘tstamp’ defaults to ‘int’ [-Wimplicit-int] cc -O3 -DRELEASE='"-20-g407cf7c"' -DCONFDIR='"/usr/local/etc/prads/"' -D__USE_GNU -c -o servicefp/servicefp.o servicefp/servicefp.c cc -O3 -DRELEASE='"-20-g407cf7c"' -DCONFDIR='"/usr/local/etc/prads/"' -D__USE_GNU -c -o servicefp/tcpc.o servicefp/tcpc.c cc -O3 -DRELEASE='"-20-g407cf7c"' -DCONFDIR='"/usr/local/etc/prads/"' -D__USE_GNU -c -o servicefp/tcps.o servicefp/tcps.c cc -O3 -DRELEASE='"-20-g407cf7c"' -DCONFDIR='"/usr/local/etc/prads/"' -D__USE_GNU -c -o servicefp/udps.o servicefp/udps.c cc -O3 -DRELEASE='"-20-g407cf7c"' -DCONFDIR='"/usr/local/etc/prads/"' -D__USE_GNU -c -o ipfp/ipfp.o ipfp/ipfp.c cc -O3 -DRELEASE='"-20-g407cf7c"' -DCONFDIR='"/usr/local/etc/prads/"' -D__USE_GNU -c -o ipfp/udp_fp.o ipfp/udp_fp.c cc -O3 -DRELEASE='"-20-g407cf7c"' -DCONFDIR='"/usr/local/etc/prads/"' -D__USE_GNU -c -o ipfp/icmp_fp.o ipfp/icmp_fp.c cc -O3 -DRELEASE='"-20-g407cf7c"' -DCONFDIR='"/usr/local/etc/prads/"' -D__USE_GNU -c -o cxt.o cxt.c cc -O3 -DRELEASE='"-20-g407cf7c"' -DCONFDIR='"/usr/local/etc/prads/"' -D__USE_GNU -c -o output-plugins/log_dispatch.o output-plugins/log_dispatch.c cc -O3 -DRELEASE='"-20-g407cf7c"' -DCONFDIR='"/usr/local/etc/prads/"' -D__USE_GNU -c -o output-plugins/log_stdout.o output-plugins/log_stdout.c cc -O3 -DRELEASE='"-20-g407cf7c"' -DCONFDIR='"/usr/local/etc/prads/"' -D__USE_GNU -c -o output-plugins/log_file.o output-plugins/log_file.c cc -O3 -DRELEASE='"-20-g407cf7c"' -DCONFDIR='"/usr/local/etc/prads/"' -D__USE_GNU -c -o output-plugins/log_fifo.o output-plugins/log_fifo.c cc -O3 -DRELEASE='"-20-g407cf7c"' -DCONFDIR='"/usr/local/etc/prads/"' -D__USE_GNU -c -o output-plugins/log_ringbuffer.o output-plugins/log_ringbuffer.c cc -O3 -DRELEASE='"-20-g407cf7c"' -DCONFDIR='"/usr/local/etc/prads/"' -D__USE_GNU -c -o output-plugins/log_sguil.o output-plugins/log_sguil.c cc -O3 -DRELEASE='"-20-g407cf7c"' -DCONFDIR='"/usr/local/etc/prads/"' -D__USE_GNU -o prads bstrlib.o sig_tcp.o config.o sys_func.o assets.o prads.o dhcp.o dump_dns.o mac.o servicefp/servicefp.o servicefp/tcpc.o servicefp/tcps.o servicefp/udps.o ipfp/ipfp.o ipfp/udp_fp.o ipfp/icmp_fp.o cxt.o output-plugins/log_dispatch.o output-plugins/log_stdout.o output-plugins/log_file.o output-plugins/log_fifo.o output-plugins/log_ringbuffer.o output-plugins/log_sguil.o -lpcap -lpcre -lresolv ** dump_dns.o:dump_dns.c:(.text+0xa8): undefined reference to "__ns_parserr" dump_dns.o:dump_dns.c:(.text+0xed): undefined reference to "__p_type" dump_dns.o:dump_dns.c:(.text+0xf9): undefined reference to "__p_class" dump_dns.o:dump_dns.c:(.text+0x1c2): undefined reference to "__ns_name_uncompress" dump_dns.o:dump_dns.c:(.text+0x225): undefined reference to "__ns_name_uncompress" dump_dns.o:dump_dns.c:(.text+0x27a): undefined reference to "__ns_name_uncompress" dump_dns.o:dump_dns.c:(.text+0x42a): undefined reference to "__ns_initparse" dump_dns.o:dump_dns.c:(.text+0x49e): undefined reference to "__ns_msg_getflag" dump_dns.o:dump_dns.c:(.text+0x50c): undefined reference to "__ns_msg_getflag" dump_dns.o:dump_dns.c:(.text+0x519): undefined reference to "__p_rcode" dump_dns.o:dump_dns.c:(.text+0x524): undefined reference to "_res_opcodes" dump_dns.o:dump_dns.c:(.text+0x5ad): undefined reference to "__ns_msg_getflag" dump_dns.o:dump_dns.c:(.text+0x621): undefined reference to "__ns_msg_getflag" dump_dns.o:dump_dns.c:(.text+0x695): undefined reference to "__ns_msg_getflag" dump_dns.o:dump_dns.c:(.text+0x709): undefined reference to "__ns_msg_getflag" dump_dns.o:dump_dns.c:(.text+0x77d): undefined reference to "__ns_msg_getflag" dump_dns.o:dump_dns.c:(.text+0x7f1): more undefined references to "__ns_msg_getflag" follow collect2: error: ld returned 1 exit status make[1]: *** [Makefile:100: prads] Error 1 ** make[1]: exit from the folder "/home/Giacomo/prads/src" make: *** [Makefile:15: build] Error 2

I've used the NPcap files with a symbolic link to the proper name as libpcap substitute. I've also modified the src/Makefile to point to the proper lib location:

for finding static libraries

#LIBDIR=/usr/lib/x86_64-linux-gnu LIBDIR=/usr/lib

But still don't work. Do you have any ideas for fixing it?

Anandir avatar Mar 09 '18 09:03 Anandir

From doc/INSTALL:

## dependencies
libpcap0.8 (>= 0.9.8), libpcre3 (>= 8.10), libresolv

comotion avatar Mar 09 '18 10:03 comotion

first occurance is ** dump_dns.o:dump_dns.c:(.text+0xa8): undefined reference to "__ns_parserr", indicates you are missing libresolv

comotion avatar Mar 09 '18 10:03 comotion

All the libraries are present. The libpcap0.8 (>= 0.9.8) is provided by NPcap (as said) so it's like the latest libpcap, but for Windows. The libpcre3 (>= 8.10) is provided by this https://cygwin.com/cgi-bin2/package-cat.cgi?file=x86%2Flibpcre1%2Flibpcre1-8.40-1&grep=libpcre, but I don't think it's the problem because the errors are related to the resolv lib. The resolv lib it's bundled within the Cygwin environment.

Anandir avatar Mar 09 '18 10:03 Anandir

That's what I've thought too. That's why I've modified the make file to the proper location, but it doesn't work, and I didn't understand why. I'm not sure of this, but if gcc link the libraries in the order of which are provided, the libresolv it's the last one, so the linking is ok for the other two. The file libresolv.a it's present in the modified LIBDIR path.

I've check the pasts issues, and used the issue #40 as source for ideas, but with no luck.

Anandir avatar Mar 09 '18 10:03 Anandir

The symbols you are missing are definitely provided by libresolv.so on my system.

Look, I am not sure anyone has ever tried prads in cygwin before. The environment might prove insufficient. You can try nm -D /path/to/libresolv.so | grep ns_parserr - maybe you have an old version, or a quirky path to your libresolv?

comotion avatar Mar 09 '18 10:03 comotion

The .so it's not present, because, if I've understood correctly from previous search over it, it's bundled inside the cygwin1.dll or, anyway, inside the cygwin framework. The only thing present it's the .a library and that's what I've with the nm -D output:

$ nm -D /usr/lib/libresolv.a

d000000.o:
nm: d000000.o: no symbol

t-d000031.o:
nm: t-d000031.o: no symbol

t-d000032.o:
nm: t-d000032.o: no symbol

t-d000033.o:
nm: t-d000033.o: no symbol

t-d000093.o:
nm: t-d000093.o: no symbol

t-d000094.o:
nm: t-d000094.o: no symbol

t-d000095.o:
nm: t-d000095.o: no symbol

t-d000096.o:
nm: t-d000096.o: no symbol

t-d000097.o:
nm: t-d000097.o: no symbol

t-d000098.o:
nm: t-d000098.o: no symbol

t-d000099.o:
nm: t-d000099.o: no symbol

t-d000100.o:
nm: t-d000100.o: no symbol

t-d000101.o:
nm: t-d000101.o: no symbol

t-d000102.o:
nm: t-d000102.o: no symbol

t-d000103.o:
nm: t-d000103.o: no symbol

t-d000104.o:
nm: t-d000104.o: no symbol

t-d000105.o:
nm: t-d000105.o: no symbol

t-d000106.o:
nm: t-d000106.o: no symbol

t-d000107.o:
nm: t-d000107.o: no symbol

The output of the nm command (without -D) is:

$ nm /usr/lib/libresolv.a

d000000.o:
00000000 i .idata$7
00000000 I _libresolv_dll_iname

t-d000031.o:
00000000 t .text
00000000 T ___dn_comp
         U __imp____dn_comp

t-d000032.o:
00000000 t .text
00000000 T ___dn_expand
         U __imp____dn_expand

t-d000033.o:
00000000 t .text
00000000 T ___dn_skipname
         U __imp____dn_skipname

t-d000093.o:
00000000 t .text
00000000 T ___res_close
         U __imp____res_close

t-d000094.o:
00000000 t .text
00000000 T ___res_init
         U __imp____res_init

t-d000095.o:
00000000 t .text
00000000 T ___res_mkquery
         U __imp____res_mkquery

t-d000096.o:
00000000 t .text
00000000 T ___res_nclose
         U __imp____res_nclose

t-d000097.o:
00000000 t .text
00000000 T ___res_ninit
         U __imp____res_ninit

t-d000098.o:
00000000 t .text
00000000 T ___res_nmkquery
         U __imp____res_nmkquery

t-d000099.o:
00000000 t .text
00000000 T ___res_nquery
         U __imp____res_nquery

t-d000100.o:
00000000 t .text
00000000 T ___res_nquerydomain
         U __imp____res_nquerydomain

t-d000101.o:
00000000 t .text
00000000 T ___res_nsearch
         U __imp____res_nsearch

t-d000102.o:
00000000 t .text
00000000 T ___res_nsend
         U __imp____res_nsend

t-d000103.o:
00000000 t .text
00000000 T ___res_query
         U __imp____res_query

t-d000104.o:
00000000 t .text
00000000 T ___res_querydomain
         U __imp____res_querydomain

t-d000105.o:
00000000 t .text
00000000 T ___res_search
         U __imp____res_search

t-d000106.o:
00000000 t .text
00000000 T ___res_send
         U __imp____res_send

t-d000107.o:
00000000 t .text
00000000 T ___res_state
         U __imp____res_state

Anandir avatar Mar 09 '18 11:03 Anandir

Well, maybe the symbols are in the cygwin dll, but the makefile expects there to be a working -lresolv to link with, and that this library provides the required symbols. If you are convinced the symbols should be provided in cygwin1.dll or some other file, try nm -D on that library to see if it contains the required symbols. prads would then need to be linked with that library.

My bet is that cygwin libresolv is broken or too old. You can try with MSYS2, which is a more up-to-date posix compatibility layer. You'll be the first one that gets this working, so be sure to report back :sweat_smile:

comotion avatar Mar 09 '18 11:03 comotion

Ok :-). I'll continue the investigations/works over it. I'll keep you posted :-)! Thanks a lot so far ;-)!

Anandir avatar Mar 09 '18 11:03 Anandir

a quick look into my crystal ball yeilded this gem from 2004: https://cygwin.com/ml/cygwin/2004-11/msg00024.html

You can try to install minires-devel in cygwin and see if that provides the needed resolver symbols.

comotion avatar Mar 09 '18 11:03 comotion

It seems that the minires-devel is now obsolete and no more available.

https://cygwin.com/cgi-bin2/package-grep.cgi?grep=minires&arch=x86

I'm installing MSYS2 at the moment.

Anandir avatar Mar 09 '18 11:03 Anandir