2

I am having some issues with a makefile I am creating for a school project. I am compiling and assembling a C file and a SPARC assembly file (respectively) and linking them. I'm working in a Unix environment. Here is the makefile:

proj09.exe: proj09.driver.o proj09.support.o
<tab>gcc -Wall proj09.driver.o proj09.support.o -o proj09.exe

proj09.driver.o: proj09.driver.c /user/cse320/Projects/project09.support.h
<tab>gcc -Wall -c proj09.driver.c /user/cse320/Projects/project09.support.h

proj09.support.o: proj09.support.s
<tab>gcc -Wall proj09.support.s 

When I try to make it, though, I get a reader error, specifically:

"Fatal error in reader: proj09.makefile, line 2: Unexpected end of line seen"

Now I know that usually this means that something is formatted incorrectly, but I have no idea what it could be in this case. Also, I am not 100% sure that this is the correct code for the makefile (specifically the assembling of my support.s file, and the linking of both files). I apologize if this is a repeat question, I looked through the archives beforehand and couldn't find anything of use. Any help would be greatly appreciated!

EDIT: I don't see why this would make a difference, but I am using gedit to actually write the code and then transferring the files into SSH for linking.

Serpent_wooer
  • 21
  • 1
  • 4
  • 1
    Most `make` programs can't handle commands with leading _spaces_, it has to be proper tab. – Some programmer dude Nov 23 '12 at 15:52
  • Sorry, I should've made that clearer, but I already have tabs in there. It's still not working. – Serpent_wooer Nov 23 '12 at 15:58
  • As a side note, perhaps you didn't mean to compile the header file `gcc -Wall -c proj09.driver.c /user/cse320/Projects/project09.support.h`. And you're missing a `-c` in `gcc -Wall proj09.support.s`. – chill Nov 23 '12 at 16:03
  • Aren't you supposed to compile the header file as well, though? Otherwise how will the function declarations and such be expressed in the resulting object file? – Serpent_wooer Nov 23 '12 at 16:07
  • No, you're supposed to `#include` the header file. In your case, you accidentally created a precompiled header. – chill Nov 23 '12 at 16:14
  • Okay, thanks, fixed that, although it's still not working :( same error... – Serpent_wooer Nov 23 '12 at 16:20

2 Answers2

2

As Joachim told you, the lines should be indented by tab, not by spaces, so the second line should look like:

[TAB]gcc -Wall proj09.driver.o proj09.support.o -o proj09.exe[NEWLINE]

where [TAB] means TAB character.

Also there shouldn't be any spaces after the command. That's why I've put [NEWLINE] char.

banuj
  • 3,080
  • 28
  • 34
  • Note that this also means no carriage return characters before the newline (just in case the OP is actually writing the makefile on Windows) – Daniel Roethlisberger Nov 23 '12 at 16:06
  • Nah, writing this in gedit, which to my knowledge puts in all the carriage returns and such (at least, I haven't had a problem with it yet). I don't think it's the editor but obviously I could be wrong. – Serpent_wooer Nov 23 '12 at 16:10
0

Aside from the spaces and tabs, this doesn't generate an object file, shouldn't even compile (unless it has main()):

gcc -Wall proj09.support.s 

You should use -c here too:

gcc -Wall -c proj09.support.s 

Note: if you're working on Unix/Linux lose the .exe

iabdalkader
  • 17,009
  • 4
  • 47
  • 74