473,414 Members | 1,876 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

what is the problem about my makefile

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
6 1882
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
"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
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
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
>"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 (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.
Apr 16 '07 #6
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Bryan Olson | last post by:
Here's the problem: Suppose we use: import socket f = some_socket.makefile() Then: f.read() is efficient, but verbose, and incorrect (or at least does not play will with others);
1
by: Jamie Saker | last post by:
I think I'm overlooking something assumed in socket's makefile method. Googling several hours and digging thru the python reference didn't help - I think I'm overlooking an assumption between...
2
by: Robert Rothenberg | last post by:
I am working on a module that when given a CPAN distribution, will return which modules the distribtion requires (by parsing the Makefile.PL using Module::MakefilePL::Parse if the META.yml file is...
4
by: newbiecpp | last post by:
I am very sorry to post this one because I know it is out of topic but I cannot find the proper news group. I understand that most senior C++ programmers know makefile very well. My question is...
2
by: Juhan Voolaid | last post by:
Hello I need help with my makefile, so that when I compile my project the source code files would be separated from the object (*.o) files. So if I have: main.cpp and classes.cpp - the...
121
by: typingcat | last post by:
First of all, I'm an Asian and I need to input Japanese, Korean and so on. I've tried many PHP IDEs today, but almost non of them supported Unicode (UTF-8) file. I've found that the only Unicode...
1
by: lem | last post by:
under solaris: # make Making all in src Making all in engine make: Fatal error in reader: Makefile, line 453: Badly formed macro assignment Current working directory...
1
by: rpjanaka | last post by:
I am using an open source library called IGI_UDP for measure the available bandwidth of a link (http://www.cs.cmu.edu/%7Ehnn/igi/ ). with that library they have provided a "Makefile" which is not an...
9
by: bowlderyu | last post by:
Hello, all. I meet a question about compiling files. Eg., I have three files named myfile.h, myfile.c and the main.c file, and there is a function, ex, void myfun(...). If I put myfun(...) in...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.