Solved

Makefile Help

Posted on 2003-10-24
15
290 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
Portable, direct connect server access

The ATEN CV211 connects a laptop directly to any server allowing you instant access to perform data maintenance and local operations, for quick troubleshooting, updating, service and repair.

 
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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.

789 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