Solved

Makefile Help

Posted on 2003-10-24
15
292 Views
Last Modified: 2010-04-15
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
0
Comment
Question by:jtcy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 3
  • 3
  • +1
15 Comments
 
LVL 4

Assisted Solution

by:n_fortynine
n_fortynine earned 150 total points
ID: 9618161
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)
0
 
LVL 6

Accepted Solution

by:
GaryFx earned 100 total points
ID: 9618234
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
0
 
LVL 4

Expert Comment

by:n_fortynine
ID: 9619884
>>Also, leave a blank line between each rule set
I don't think that is necessary???
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 6

Expert Comment

by:GaryFx
ID: 9622242
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.
0
 

Author Comment

by:jtcy
ID: 9625269
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.
0
 
LVL 4

Expert Comment

by:n_fortynine
ID: 9625277
have you tried removing that 3rd line and run makefile again?
0
 

Author Comment

by:jtcy
ID: 9625289
I tried, it;s still the same error
0
 
LVL 4

Expert Comment

by:n_fortynine
ID: 9625334
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?
0
 

Author Comment

by:jtcy
ID: 9625346
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
0
 
LVL 4

Expert Comment

by:n_fortynine
ID: 9625355
Try to create makefile on UNIX instead of windows. That might have something to do the way Windows creates text files.
0
 
LVL 6

Expert Comment

by:GaryFx
ID: 9626216
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
0
 
LVL 4

Expert Comment

by:n_fortynine
ID: 9826544
The points should be split between Gary and myself. The questioner never followed up anyway.
0
 
LVL 45

Expert Comment

by:sunnycoder
ID: 9886728
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
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question