Installing tree-1.6.0 in cygwin. What am I missing

2019-07-22 11:31发布

问题:

I am trying to install tree 1.6.0 in my cygwin console. To do that, I downloaded the source.

Here is the content of the file

  ===> ls -lh
total 269K
-rw-r--r--  1 user None 8.8K Jun 24  2011 CHANGES
-rw-r--r--  1 user None  16K Jun 22  2011 color.c
-rw-r--r--  1 user None  17K Apr 14 11:35 color.o
drwxr-xr-x+ 1 user None    0 Apr 14 11:35 doc
-rw-r--r--  1 user None 3.1K Jun 24  2011 hash.c
-rw-r--r--  1 user None 2.4K Apr 14 11:35 hash.o
-rw-r--r--  1 user None  15K Jun 24  2011 html.c
-rw-r--r--  1 user None  21K Apr 14 11:35 html.o
-rw-r--r--  1 user None  596 Jun 24  2011 INSTALL
-rw-r--r--  1 user None  18K Aug 12  2004 LICENSE
-rw-r--r--  1 user None 2.6K Jun 24  2011 Makefile
-rw-r--r--  1 user None 4.6K Jun 24  2011 README
-rw-r--r--  1 user None 5.2K Aug 27  2008 strverscmp.c
-rw-r--r--  1 user None 2.2K Jun 24  2011 TODO
-rw-r--r--  1 user None  31K Jun 24  2011 tree.c
-rw-r--r--  1 user None 5.0K Jun 24  2011 tree.h
-rw-r--r--  1 user None  37K Apr 14 11:35 tree.o
-rw-r--r--  1 user None 7.4K Jun 22  2011 unix.c
-rw-r--r--  1 user None  11K Apr 14 11:35 unix.o
-rw-r--r--  1 user None 8.7K Jun 24  2011 xml.c
-rw-r--r--  1 user None  13K Apr 14 11:35 xml.o

When I run make, the following is what I get:

   ===> make
gcc -O4 -Wall  -DLINUX -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -c -o tree.o tree.c
tree.c: In function ‘main’:
tree.c:481:7: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 3 has type                                                                                          ‘off_t’ [-Wformat=]
       if (duflag) fprintf(outfile,"    <size>%lld</size>\n", size);
       ^
tree.c:481:7: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 3 has type                                                                                          ‘off_t’ [-Wformat=]
tree.c: In function ‘versort’:
tree.c:782:5: warning: implicit declaration of function ‘strverscmp’ [-Wimplicit-function-declaration]
     if ((*a)->isdir == (*b)->isdir) return strverscmp((*a)->name,(*b)->name);
     ^
tree.c: In function ‘psize’:
tree.c:1107:3: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 3 has type                                                                                          ‘off_t’ [-Wformat=]
   } else return sprintf(buf, sizeof(off_t) == sizeof(long long)? " %11lld" : " %9ld", size);
   ^
tree.c:1107:3: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 3 has type                                                                                          ‘off_t’ [-Wformat=]
gcc -O4 -Wall  -DLINUX -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -c -o unix.o unix.c
gcc -O4 -Wall  -DLINUX -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -c -o html.o html.c
gcc -O4 -Wall  -DLINUX -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -c -o xml.o xml.c
xml.c: In function ‘xml_fillinfo’:
xml.c:301:3: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 3 has type ‘                                                                                         off_t’ [-Wformat=]
   if (sflag) fprintf(outfile, " size=\"%lld\"", ent->size);
   ^
xml.c:301:3: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 3 has type ‘                                                                                         off_t’ [-Wformat=]
gcc -O4 -Wall  -DLINUX -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -c -o hash.o hash.c
gcc -O4 -Wall  -DLINUX -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -c -o color.o color.c
gcc -s -o tree tree.o unix.o html.o xml.o hash.o color.o
tree.o:tree.c:(.text+0x1ba): undefined reference to `strverscmp'
tree.o:tree.c:(.text+0x1ba): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `strve                                                                                         rscmp'
/usr/bin/ld: tree.o: bad reloc address 0x0 in section `.data'
/usr/bin/ld: final link failed: Invalid operation
collect2: error: ld returned 1 exit status
Makefile:86: recipe for target 'tree' failed
make: *** [tree] Error 1

What is wrong and how can I fix this?

回答1:

You should follow the instructions in the document INSTALL, in the top level of the distribution directory. In particular the first step:

1. Edit the Makefile for your OS.