0

My code is a spellchecker program that checks words from an input file and that checks those words from the inputfile with a dictionary file.

I am trying to create a makefile and keep getting this error here makefile:2: *** missing separator. Stop. In Addition, I am writing my code in repl.it.

I don't know what is happening or why it is doing that?

This is my makefile contents:

a.out: main.o spell_lib.o spell.o
  gcc *.o

main.o: main.c spell_lib.h spell_lib.c
     gcc -c main.c

spell_lib.o: spell_lib.h spell_lib.c
    gcc -c spell_lib.c
AnonCham
  • 1
  • 2
  • Does this answer your question? [Make error: missing separator](https://stackoverflow.com/questions/920413/make-error-missing-separator) – kaylum Oct 25 '21 at 03:00
  • I dont believe so because my other repl.it repls makefiles are made the same why i made them. Im also not using the space bar but am hitting tab – AnonCham Oct 25 '21 at 03:15
  • I do have spaces after a.out: main.o spell.o etc etc though. I will check if thats the issue tmrw – AnonCham Oct 25 '21 at 03:19
  • "*I do have space*". Your comments are unclear. It needs to be tabs not spaces. The makefile you have shown has inconsistent indenting which implies some or all of it is not using correct tabs. For example the `gcc -c main.c` is not the same indent as the other `gcc` lines. – kaylum Oct 25 '21 at 03:21
  • Hmm thats odd, in repl.it it shows theyre indented correctly, but when i copy and paste in here its different. – AnonCham Oct 25 '21 at 03:24
  • Just to let you know, @AnonCham, you did not have to post the source code. The only problem is in the Makefile. – ADBeveridge Oct 25 '21 at 03:54
  • regarding: `while(!feof(inputFile)){` Please read [why while(!feof(inputFile)) is always wrong)](https://stackoverflow.com/questions/5431941/why-is-while-feof-file-always-wrong) – user3629249 Oct 25 '21 at 05:12
  • A note: just because you pressed the TAB key doesn't mean that the makefile written to the disk has a TAB. Some editors will insert spaces when you press TAB. Some editors will convert a TAB character to spaces when they save the file. You need to use an editor that doesn't make these "helpful" changes when working with makefiles. – MadScientist Oct 25 '21 at 13:37
  • Some other comments on your makefile: `main.o` should not have `spell_lib.c` in its dependency list. The two files will compile separately. and `gcc *.o` can be replaced with `gcc $^`. `$^` will be substituted with everything in the target's dependency list. You can also use `$<`, which will be replaced by just the first dependency in your dependency list, which is useful for targets building object files since typically you'll have a single source file as a dependency, which needs to be passed into your compiler, and a bunch of header files which do not. – Christian Gibbons Oct 25 '21 at 14:28

2 Answers2

0

regarding: gcc *.o

this line must begin with a <tab> not a space

user3629249
  • 16,402
  • 1
  • 16
  • 17
0

I was able to fix the issue, i just went and copied and pasted my code i had previously created in putty which has the correct indentations.

AnonCham
  • 1
  • 2