3

I revised a project a bit, under debugging it worked fine. When I try to build it without debugging, it is showing errors, could not fix it.

        $ make
        Making all in third_party
        make[1]: Entering directory '/cygdrive/c/Users/alimjan/Documents/fast-hlground/slim-2.2.7/third_party'
        Making all in zdelta-2.1
        make[2]: Entering directory '/cygdrive/c/Users/alimjan/Documents/fast-hlground/slim-2.2.7/third_party/zdelta-2.1'
        gcc -DHAVE_CONFIG_H -I. -I../../src     -Wall -export-dynamic -O3  -fopenmp -MT inffast.o -MD -MP -MF .deps/inffast.Tpo -c -o inffast.     o inffast.c
        mv -f .deps/inffast.Tpo .deps/inffast.Po
        gcc -DHAVE_CONFIG_H -I. -I../../src     -Wall -export-dynamic -O3  -fopenmp -MT inflate.o -MD -MP -MF .deps/inflate.Tpo -c -o inflate.     o inflate.c
       mv -f .deps/inflate.Tpo .deps/inflate.Po
       gcc -DHAVE_CONFIG_H -I. -I../../src     -Wall -export-dynamic -O3  -fopenmp -MT inftrees.o -MD -MP -MF .deps/inftrees.Tpo -c -o inftre     es.o inftrees.c
       mv -f .deps/inftrees.Tpo .deps/inftrees.Po
       gcc -DHAVE_CONFIG_H -I. -I../../src     -Wall -export-dynamic -O3  -fopenmp -MT infutil.o -MD -MP -MF .deps/infutil.Tpo -c -o infutil.     o infutil.c
       mv -f .deps/infutil.Tpo .deps/infutil.Po
       gcc -DHAVE_CONFIG_H -I. -I../../src     -Wall -export-dynamic -O3  -fopenmp -MT adler32.o -MD -MP -MF .deps/adler32.Tpo -c -o adler32.     o adler32.c
       mv -f .deps/adler32.Tpo .deps/adler32.Po
       gcc -DHAVE_CONFIG_H -I. -I../../src     -Wall -export-dynamic -O3  -fopenmp -MT zd_mem.o -MD -MP -MF .deps/zd_mem.Tpo -c -o zd_mem.o z     d_mem.c
       mv -f .deps/zd_mem.Tpo .deps/zd_mem.Po
       gcc -DHAVE_CONFIG_H -I. -I../../src     -Wall -export-dynamic -O3  -fopenmp -MT zutil.o -MD -MP -MF .deps/zutil.Tpo -c -o zutil.o zuti     l.c
       mv -f .deps/zutil.Tpo .deps/zutil.Po
       rm -f libzd_in_slim.a
       ar cru libzd_in_slim.a deflate.o infblock.o infcodes.o inffast.o 
       inflate.o inftrees.o infutil.o adler32.o trees.o zd_mem.o zdelta.o zu     til.o
       ranlib libzd_in_slim.a
       make[2]: Leaving directory '/cygdrive/c/Users/alimjan/Documents/fast-hlground/slim-2.2.7/third_party/zdelta-2.1'
       make[2]: Entering directory '/cygdrive/c/Users/alimjan/Documents/fast-hlground/slim-2.2.7/third_party'
      make[2]: Nothing to be done for 'all-am'.
      make[2]: Leaving directory '/cygdrive/c/Users/alimjan/Documents/fast-hlground/slim-2.2.7/third_party'
      make[1]: Leaving directory '/cygdrive/c/Users/alimjan/Documents/fast-hlground/slim-2.2.7/third_party'
      Making all in src
      make[1]: Entering directory '/cygdrive/c/Users/alimjan/Documents/fast-hlground/slim-2.2.7/src'
      /bin/sh ./genconfig
      ./genconfig: line 2: $'\r': command not found
      ./genconfig: line 8: $'\r': command not found
      ./genconfig: line 10: $'\r': command not found
      ./genconfig: line 13: $'\r': command not found
      ./genconfig: line 16: $'\r': command not found
      ./genconfig: line 19: $'\r': command not found
      ./genconfig: line 20: $'cat\r': command not found
      ./genconfig: line 21: $'cat\r': command not found
      ./genconfig: line 22: $'\r': command not found
      ./genconfig: line 61: $'\r': command not found
      ./genconfig: line 62: $'\r': command not found
      ./genconfig: line 86: $'\r': command not found
      ./genconfig: line 87: $'\r': command not found
      ./genconfig: line 88: $'\r': command not found
      make[1]: *** [Makefile:1558: arch.h] Error 127
       make[1]: Leaving directory '/cygdrive/c/Users/alimjan/Documents/fast-hlground/slim-2.2.7/src'
       make: *** [Makefile:425: all-recursive] Error 1

Now, I could not build it with/without debugging. How can I fix this? Please help

Paul Rooney
  • 20,879
  • 9
  • 40
  • 61
arslan
  • 2,034
  • 7
  • 34
  • 61
  • 1
    probably windows line endings `\r\n` instead of just `\n`. See [this](http://stackoverflow.com/questions/11616835/r-command-not-found-bashrc-bash-profile) answer. – Paul Rooney Apr 29 '17 at 07:50
  • @PaulRooney You mean in c program use '\r\n' instead of '\n'? – arslan Apr 29 '17 at 07:52
  • 1
    Whatever file `genconfig` is reading is causing it to be unhappy about the `\r` (carriage return) characters, which are a typical symptom of a text file having been copied from Windows without removing the carriage returns. – Jonathan Leffler Apr 29 '17 at 07:54

2 Answers2

7

genconfig is a shell script and it is written with DOS line endings. This line ending confuses the /bin/sh shell when running the script. You should convert to unix line endings with dos2unix.

fjardon
  • 7,921
  • 22
  • 31
  • I am installing dost2unix. so I have to run it on genconfig once? – arslan Apr 29 '17 at 08:07
  • I run it as ": dostounix genconfig", then run './configure' and 'make', still not working. am I doing something wrong? – arslan Apr 29 '17 at 08:10
  • @arslan can you rerun dos2unix and just run make again without ./configure ? – fjardon Apr 29 '17 at 08:14
  • There was another 'genconfig.in' file. After running dos2unit on both 'genconfig' and 'genconfi.in', then it worked. You helped me a lot, now I can sleep, lol! Thank you :) – arslan Apr 29 '17 at 08:16
6

Its End of Line(EOL) conversion issue when script is written in windows using some editors like notepad, notepad++(tested).

Notepad++ has an option to convert END OF LINE CONVERSION(EOL). How to do that: go to Edit > EOL Conversion > select Unix/OSX

Here you go, save script file and run it.It will works.

Dhananjayan K
  • 175
  • 2
  • 11