Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > what is the problem about my makefile

Reply
Thread Tools

what is the problem about my makefile

 
 
dolphin
Guest
Posts: n/a
 
      04-16-2007
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

 
Reply With Quote
 
 
 
 
Peter Nilsson
Guest
Posts: n/a
 
      04-16-2007
On Apr 16, 10:53 am, "dolphin" <jdxyw2...@gmail.com> 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.


The program we can help you with. The makefile aspect is
off topic.

--
Peter

 
Reply With Quote
 
 
 
 
R Smith
Guest
Posts: n/a
 
      04-16-2007
"dolphin" <> wrote 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).

 
Reply With Quote
 
CBFalconer
Guest
Posts: n/a
 
      04-16-2007
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

 
Reply With Quote
 
Bill Pursell
Guest
Posts: n/a
 
      04-16-2007
On Apr 16, 1:53 am, "dolphin" <jdxyw2...@gmail.com> wrote:

> 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.


 
Reply With Quote
 
Chris Torek
Guest
Posts: n/a
 
      04-16-2007
>"dolphin" <> wrote 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 <Xns9913E4458BC79rhsmith52comcastnet@216.196.97.13 1>,
R Smith <> wrote:
>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 (40°39.22'N, 111°50.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.
 
Reply With Quote
 
Kenny McCormack
Guest
Posts: n/a
 
      04-16-2007
In article <>,
Chris Torek <> wrote:
....
>>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)

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
problem in makefile raju2000myin@gmail.com C Programming 9 06-18-2007 10:07 PM
A Problem with makefile. prasadjoshi124@gmail.com C Programming 3 11-29-2006 05:33 PM
problem with a makefile fabio C Programming 4 03-10-2006 07:05 PM
javac vs Makefile problem ... for.fun@laposte.net Java 16 12-06-2005 06:09 PM
Is There A Problem With makefile() On Win32? John Abel Python 0 09-29-2003 06:12 PM



Advertisments