0

Hi,

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?

3
Contributors
4
Replies
5
Views
7 Years
Discussion Span
Last Post by thekashyap
0

A missing separator usually means that the rule line doesn't start with the tab. Make sure that there's no empty line between the dependency and the rule, and that the rule is indented with the tab - spaces do not work.

0

Thank you,I fix my code.But now,I take "There is no rule to compile myprog.c, 'myprog.o'needs this " named error.Please help me it is very urgent for me!

Edited by virtue: n/a

0

This, in turn, means that there's no myprog.c file. I can't possibly know why. Check the spelling (including upper/lower case).

0

You need to create a rule to convert .c (or .cxx, .cpp) file into a .o file.
Something like:
*.o: *.C
gcc ...

It's been 4 years so I forgot the syntax. :)
But this bare-bone Makefile. You should be able to find an example from the gcc documentation itself.
Else just google for makefile template and you should find one you can use.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.