Reputation: 633
I can not create executable code by using a makefile. How can I generate the executable code. I wrote this lines into my makefile and in the terminal I wrote make but I can not do it. Please help me.
myprog : myprog.o mylibrary.o
gcc myprog.o mylibrary.o -o myprog
myprog.o : myprog.c mylibrary.h
gcc -c myprog.c mylibrary.h -o myprog.o
mylibrary.o : mylibrary.c mylibrary.h
gcc -c mylibrary.c -o mylibrary.o
I take lost separator error. How can I fix this?
Upvotes: 0
Views: 233
Reputation: 15734
Try this
myprog : myprog.o mylibrary.o
gcc myprog.o mylibrary.o -o myprog
myprog.o :
gcc -c myprog.c
mylibrary.o :
gcc -c mylibrary.c
Upvotes: 0
Reputation: 11775
Try to add -o
after the other calls to gcc. Also, be sure you typed \t
(tab key) in the indentation (not white spaces, but a real tab char). Be sure your text editor is not configured to use white spaces instead of tabs if this is the case.
myprog : myprog.o mylibrary.o
gcc myprog.o mylibrary.o -o myprog
myprog.o : myprog.c mylibrary.h
gcc -c myprog.c mylibrary.h -o myprog.o
mylibrary.o : mylibrary.c mylibrary.h
gcc -c mylibrary.c -o mylibrary.o
Please, when writing a question, never forget to tell the error messages you get. This helps identifying the problem and give an accurate answer.
I hope this helps you. Take care, Beco
Upvotes: 1