By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,508 Members | 1,856 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,508 IT Pros & Developers. It's quick & easy.

what is the problem about my makefile

P: n/a
Hi! I am learing makefile recently.Now I have a problem.
I write a very simple program just like "hello world"
I write two makefile for it.One is included in another.
the first is makefile
include mainmake.mk
example:main.o
cc -o example main.o
clean:
rm -f *.o

this is the second makefile named mainmake.mk which is included in
makefile.
main.o:main.c head.h
cc -c -g main.c

when I type make command in shell.Only main.o file is created.The file
main did not be created.What is the problem?I am in redhat 9.0

Apr 16 '07 #1
Share this Question
Share on Google+
6 Replies


P: n/a
On Apr 16, 10:53 am, "dolphin" <jdxyw2...@gmail.comwrote:
Hi! I am learing makefile recently.Now I have a problem.
I write a very simple program just like "hello world"
I write two makefile for it.
The program we can help you with. The makefile aspect is
off topic.

--
Peter

Apr 16 '07 #2

P: n/a
"dolphin" <jd*******@gmail.comwrote in news:1176684813.213582.98550
@l77g2000hsb.googlegroups.com:
Hi! I am learing makefile recently.Now I have a problem.
I write a very simple program just like "hello world"
I write two makefile for it.One is included in another.
the first is makefile
include mainmake.mk
example:main.o
cc -o example main.o
clean:
rm -f *.o

this is the second makefile named mainmake.mk which is included in
makefile.
main.o:main.c head.h
cc -c -g main.c

when I type make command in shell.Only main.o file is created.The file
main did not be created.What is the problem?I am in redhat 9.0

Off topic, off schmopic, who cares? You need help.

Try this:

cc -o example main.c

You can't compile a .o file. You can say I want to compile a .c program
and call it this (-o).

Apr 16 '07 #3

P: n/a
dolphin wrote:
>
Hi! I am learing makefile recently.Now I have a problem.
I write a very simple program just like "hello world"
I write two makefile for it.One is included in another.
the first is makefile

include mainmake.mk
example:main.o
cc -o example main.o
clean:
rm -f *.o

this is the second makefile named mainmake.mk which is included in
makefile.
main.o:main.c head.h
cc -c -g main.c

when I type make command in shell.Only main.o file is created.The file
main did not be created.What is the problem?I am in redhat 9.0
That creates main.o, which will be the relocatable object version
of your c file. To create the runnable final file you need to
execute:

cc -o main main.o

which you express (in the make file) as:

main : main.o #the dependency
cc -o main main.o #the command to execute

Note that the commands have a leading tab char.

--
<http://www.cs.auckland.ac.nz/~pgut001/pubs/vista_cost.txt>
<http://www.securityfocus.com/columnists/423>
<http://www.aaxnet.com/editor/edit043.html>

"A man who is right every time is not likely to do very much."
-- Francis Crick, co-discover of DNA
"There is nothing more amazing than stupidity in action."
-- Thomas Matthews

--
Posted via a free Usenet account from http://www.teranews.com

Apr 16 '07 #4

P: n/a
On Apr 16, 1:53 am, "dolphin" <jdxyw2...@gmail.comwrote:
I write a very simple program just like "hello world"
I write two makefile for it.One is included in another.
the first is makefile
include mainmake.mk
example:main.o
cc -o example main.o
This is off-topic here, but if you
insert your included makefile by hand,
you'll see that invoking make with no
arguments is equivalent to invoking:
"make main.o" since main.o is the
first target. Try moving the include
line below the example target.
Apr 16 '07 #5

P: n/a
>"dolphin" <jd*******@gmail.comwrote in news:1176684813.213582.98550
>@l77g2000hsb.googlegroups.com:
>Hi! I am learing makefile recently. ...
[makefile snipped]
>when I type make command in shell. Only main.o file is created. The file
main did not be created. What is the problem? I am in redhat 9.0
You want comp.unix.programmer, or a linux-specific newsgroup (although
the former will suffice here).

In article <Xn*********************************@216.196.97.13 1>,
R Smith <rh*******@comcast.netwrote:
>Off topic, off schmopic, who cares? You need help.
Well, "dolphin" may care, since you have given him an incorrect
answer. :-)
>Try this:

cc -o example main.c
Although that can be made to work, it is not what he should be
doing in this case.
>You can't compile a .o file.
Depending on the system, you *can*, depending on just what one
means by "compile" ... and RedHat Linux is one of those where you
can, and he has done the right things to make the given .o file
"compile-able".

For more information, try comp.unix.programmer.
--
In-Real-Life: Chris Torek, Wind River Systems
Salt Lake City, UT, USA (4039.22'N, 11150.29'W) +1 801 277 2603
email: forget about it http://web.torek.net/torek/index.html
Reading email is like searching for food in the garbage, thanks to spammers.
Apr 16 '07 #6

P: n/a
In article <ev*********@news4.newsguy.com>,
Chris Torek <no****@torek.netwrote:
....
>>You can't compile a .o file.

Depending on the system, you *can*, depending on just what one
means by "compile" ... and RedHat Linux is one of those where you
can, and he has done the right things to make the given .o file
"compile-able".
I think the statement "You can't compile a .o file." is technically
true, but moot. It is much akin to the statement that you can't bake a
cake. This last is true, since at the point in time when it is baking,
it is not a cake, but merely a bunch of ingredients mixed together in a
pan. Only when the baking is finished, is it a cake.

But I think most of us would agree that both statements are pretty silly
(though I daresy they might well appeal to the idiots^Wpedants in this ng)

Apr 16 '07 #7

This discussion thread is closed

Replies have been disabled for this discussion.