• C

Makefile Help

i need to make a makefile first, to produce 16 files. I have try1.c, try2.c .....till try16.c. I need to run make to produce these 16 files,. and i have now:

list_file_1: try1.o
     cc -o list_file_1 try1.o
try1.o: try1.c
     cc -c try1.c

i donno wats wrong with them~~~ :____(

the error: 'ake: Fatal error: Don't know how to make target `try1.o
jtcyAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

n_fortynineCommented:
which one is your main (driver) file? you're telling it in the first line:
>>list_file_1: try1.o
while it should be a .c file

an example:
prog: prog.cpp file1.o file2.o
        CC -o prog prog.cpp file1.o file2.o
file1.o: file1.cpp file1.h
        CC -c file1.cpp
file2.o: file2.cpp file2.h
        CC -c file2.cpp

etc. (The .h part is just for when you have it)
GaryFxCommented:
Make sure that the command lines (i.e. the lines that begin with cc) begin with a tab character, and not spaces.  Also, leave a blank line between each rule set (i.e. between the cc -o list_file_1 try1.o and the try1.o : try 1.c.

Gary

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
n_fortynineCommented:
>>Also, leave a blank line between each rule set
I don't think that is necessary???
Acronis True Image 2019 just released!

Create a reliable backup. Make sure you always have dependable copies of your data so you can restore your entire system or individual files.

GaryFxCommented:
I don't think it's necessary, either, but I've never seen a makefile that didn't do it that way.  It's just good style.
jtcyAuthor Commented:
I am so sick of this, i now have:

list_file_1: list_file_1.c try1.o
    cc -o list_file_1 list_file_1.c try1.o

try1.o: try1.c
    cc -c try1.c

it says unexpected end of line seen in line 3. what;s wrong with it? I need to make a file called list_file_1.c by using just try1.c only. I am very sure the second and the fifth line start with a tab.
n_fortynineCommented:
have you tried removing that 3rd line and run makefile again?
jtcyAuthor Commented:
I tried, it;s still the same error
n_fortynineCommented:
So you wrote this and it still says "unexpected end of line seen in line 3"?

list_file_1: list_file_1.c try1.o
    cc -o list_file_1 list_file_1.c try1.o
try1.o: try1.c
    cc -c try1.c

What compiler/OS are you using to run makefile? And did you create the makefile file from Windows by any chance?
jtcyAuthor Commented:
yes, that;s wat i have. um~~~ i wrote that at home on windows xp and then ssh to my sch;s server which is unix solaris i think
n_fortynineCommented:
Try to create makefile on UNIX instead of windows. That might have something to do the way Windows creates text files.
GaryFxCommented:
Or, if your UNIX system has a dos2unix command, run it on the file.

UNIX make is very picky with respect to characters.  It insists on tabs for command lines (no faking it with a bunch of space characters) and newlines (no carriage returns).  The convention on Microsoft operating systems is to do line breaks with CRLFs (carriage return, new line pairs).  Thus, this breaks some older programs on UNIX.

Gary
n_fortynineCommented:
The points should be split between Gary and myself. The questioner never followed up anyway.
sunnycoderCommented:
No comment has been added lately and this question is therefore classified abandoned.

If asker wishes to close the question, then refer to
http://www.experts-exchange.com/help/closing.jsp

Otherwise, I will leave a recommendation in the Cleanup topic area that this question is:
PAQed with 150:100 split between  n_fortynine and GaryFx

Please leave any comments here within the next seven days. It is assumed that any participant not responding to this request is no longer interested in its final disposition.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Sunny
EE Cleanup Volunteer
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C

From novice to tech pro — start learning today.