Solved

Makefile Help

Posted on 2003-10-24
15
289 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
  • 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
NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

 
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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Suggested Solutions

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops 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.

832 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