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?

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.

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!

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

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.