Click here to Skip to main content
15,885,141 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am having a file/folder structure like this
"MY" folder contain
main.c

then "My" folder contain two other folders named "source" and "header"

main.c has references to header files that are in the "header" folder.
The *.c source files (that are in the source directory) has there header files in "header" directory.

So i have written the make files like this

program: main.o CPU.o OS.o RAM.o snmputil.o UTILITY_FUNCTION.o

main.o: main.c /header/OS.h /header/snmputil.h /header/CPU.h
        gcc -o main.c

CPU.o: /source/CPU.c ../header/CPU.h
        gcc -o /source/CPU.c


OS.o: OS.c ../header/OS.h
        gcc -c /source/OS.c

UTILITY_FUNCTION.o: /source/UTILITY_FUNCTION.c ../header/UTILITY_FUNCTION.h
        gcc -c /source/UTILITY_FUNCTION.c




when i do make on the makefile i get the error

missing separator.  Stop.


Please guide
Posted

1 solution

Quote:
main.o: main.c /header/OS.h /header/snmputil.h /header/CPU.h
gcc -o main.c
Should be:
main.o: main.c header/OS.h header/snmputil.h header/CPU.h
        gcc -I header -c main.c



Quote:
CPU.o: /source/CPU.c ../header/CPU.h
gcc -o /source/CPU.c
Should be:
CPU.o: ../source/CPU.c ../header/CPU.h
        gcc -I../header -c /source/CPU.c


and so on.

Moreover, make sure you (and your editor as well) are using tabs instead of blanks, before compiling directives (i.e. before gcc).
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900