Friday, April 11, 2014

Installing SLOCCount in Cygwin

wget http://www.dwheeler.com/sloccount/sloccount-2.26.tar.gz
tar xzvf sloccount-2.26.tar.gz
cd sloccount-2.26/
EXE_SUFFIX=.exe
make EXE_SUFFIX=.exe
make install

Done!

6 comments:

  1. Sounds simple but doesn't work for me with CygWin64 and having installed missing tools like wget, make, flex etc:

    $ make EXE_SUFFIX=.exe
    gcc -Wall pascal_count.c -o pascal_count.exe
    /usr/lib/gcc/x86_64-pc-cygwin/4.9.2/../../../../lib/libcygwin.a(libcmain.o): In function `main':
    /usr/src/debug/cygwin-1.7.33-1/winsup/cygwin/lib/libcmain.c:39: undefined reference to `WinMain'
    /usr/src/debug/cygwin-1.7.33-1/winsup/cygwin/lib/libcmain.c:39:(.text.startup+0x7e): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `WinMain'
    collect2: Fehler: ld gab 1 als Ende-Status zurück
    makefile:143: recipe for target 'pascal_count.exe' failed
    make: *** [pascal_count.exe] Error 1

    ReplyDelete
    Replies
    1. Hey!

      Sorry that it doesn't work.... :-(

      Here's how I did it on my machine. I don't know what might be wrong with yours.

      michael.jones@MJ200286L ~
      $ rm -rf sloccount-2.26*

      michael.jones@MJ200286L ~
      $ wget http://www.dwheeler.com/sloccount/sloccount-2.26.tar.gz
      --2015-01-28 20:21:34-- http://www.dwheeler.com/sloccount/sloccount-2.26.tar.gz
      Resolving www.dwheeler.com (www.dwheeler.com)... 208.86.184.80
      Connecting to www.dwheeler.com (www.dwheeler.com)|208.86.184.80|:80... connected.
      HTTP request sent, awaiting response... 200 OK
      Length: 190948 (186K) [application/x-gzip]
      Saving to: ‘sloccount-2.26.tar.gz’

      sloccount-2.26.tar.gz 100%[====================================================================================================================================================================>] 186.47K 451KB/s in 0.4s

      2015-01-28 20:21:34 (451 KB/s) - ‘sloccount-2.26.tar.gz’ saved [190948/190948]


      michael.jones@MJ200286L ~
      $ tar xzvf sloccount-2.26.tar.gz
      sloccount-2.26/ada_count
      sloccount-2.26/append_license
      sloccount-2.26/append_specname
      sloccount-2.26/asm_count
      ........ truncating for character limit reasons........
      sloccount-2.26/testcode/hello1.pas
      sloccount-2.26/testcode/hello.pas
      sloccount-2.26/testcode/hello.f
      sloccount-2.26/testcode/hello.f90
      sloccount-2.26/testcode/test1.lhs
      sloccount-2.26/testcode/test2.lhs
      sloccount-2.26/TODO
      sloccount-2.26/TODO.orig
      sloccount-2.26/usc_subset.tar

      michael.jones@MJ200286L ~
      $ cd sloccount-2.26/

      michael.jones@MJ200286L ~/sloccount-2.26
      $ EXE_SUFFIX=.exe

      michael.jones@MJ200286L ~/sloccount-2.26
      $ make EXE_SUFFIX=.exe
      gcc -Wall c_count.c -o c_count.exe
      cp -p c_count.exe java_count.exe
      gcc -Wall lexcount1.c -o lexcount1.exe
      flex -Cfe -t pascal_count.l > pascal_count.c
      gcc -Wall pascal_count.c -o pascal_count.exe
      :1285:17: warning: ‘yyunput’ defined but not used [-Wunused-function]
      :1326:16: warning: ‘input’ defined but not used [-Wunused-function]
      gcc -Wall php_count.c -o php_count.exe
      php_count.c: In function ‘strstrip’:
      php_count.c:140:2: warning: array subscript has type ‘char’ [-Wchar-subscripts]
      for (p= s + strlen(s) - 1; p >= s && isspace(*p); p--) {
      ^
      flex -Cfe -t jsp_count.l > jsp_count.c
      gcc -Wall jsp_count.c -o jsp_count.exe
      :1350:17: warning: ‘yyunput’ defined but not used [-Wunused-function]
      :1391:16: warning: ‘input’ defined but not used [-Wunused-function]
      gcc -Wall ml_count.c -o ml_count.exe

      michael.jones@MJ200286L ~/sloccount-2.26
      $ make install
      install ada_count asm_count awk_count break_filelist cobol_count compute_all compute_sloc_lang count_extensions count_unknown_ext csh_count exp_count fortran_count f90_count generic_count get_sloc get_sloc_details haskell_count lex_count lisp_count make_filelists makefile_count modula3_count objc_count perl_count print_sum python_count ruby_count sed_count sh_count show_filecount sloccount sql_count tcl_count c_count java_count lexcount1 pascal_count php_count jsp_count ml_count /usr/local/bin
      install -d /usr/local/share/man/man1
      install sloccount.1.gz /usr/local/share/man/man1
      install -d /usr/local/share/doc/sloccount-2.26-1
      install sloccount.html README TODO ChangeLog /usr/local/share/doc/sloccount-2.26-1

      michael.jones@MJ200286L ~/sloccount-2.26
      $



      Good luck!

      Delete
    2. Delete the whole directory and re-untar the archive. The 'make clean' does not delete the intermediate files, so if you ran into an error because say flex wasn't installed, pascal_count.c is actually an empty file.

      Delete
  2. Hi,

    I am getting the following error when tried to run "make EXE_SUFFIX=.exe"

    gcc -Wall c_count.c -o c_count.exe
    cp -p c_count.exe java_count.exe
    gcc -Wall lexcount1.c -o lexcount1.exe
    flex -Cfe -t pascal_count.l > pascal_count.c
    flex: fatal internal error, exec of /usr/bin/m4 failed
    make: *** [makefile:140: pascal_count.c] Error 1


    Please help me how to fix it.

    Many thanks in advance.

    ReplyDelete
    Replies
    1. Just use

      $ sudo apt-get install sloccount

      It has wasted me a lot of time to make and faied.

      Delete
  3. I had the same problem you had. However when I ran "sudo apt-get install sloccount" I dont have "apt-get":
    "Unable to start 'apt-get': The specified file was not found."
    Also the mirror sites associated with setup-x86_64.exe dont seem to have "apt-get". Do you know where I get it for CygWin64

    ReplyDelete