Solved

Make

Posted on 2004-09-28
8
251 Views
Last Modified: 2010-04-15
I have got 3 files.

main1.c which in there I will include node.h
node.c which in there I will include node.h
node.h

How do I create a makefile and compile them? The executable should be named "linked_list". Do you all have got any good documentation with examples on how to create a makefile?

thanks a lot.
0
Comment
Question by:ansi_c
8 Comments
 
LVL 23

Expert Comment

by:brettmjohnson
ID: 12171290
The details of the compiler etc depend on the platform and compiler environment.
But the dependencies are:

Unix makefile:

linked_list:      main1.o node.o
                  linker commands here

main1.o:            main1.c node.h
                  compile main1 command here

node.o:            node.c node.h
                  compile node command here


MS-DOS/Windows makefile:

linked_list.exe:      main1.obj node.obj
                  linker commands here

main1.obj:      main1.c node.h
                  compile main1 command here

node.obj:      node.c node.h
                  compile node command here

0
 

Author Comment

by:ansi_c
ID: 12172026
try this

main1 : main1.o node.o
cc -o main1 main1.o node.o
main1.o : main1.c node.h
cc -c main1.c
node.o : node.c node.h
cc -c node.c
clean : rm main1.o node.o


But result in an error when I typed "make"
    Makefile:2: *** missing separator.  Stop.

0
 

Author Comment

by:ansi_c
ID: 12172057
i am using Solaris
0
 
LVL 23

Assisted Solution

by:brettmjohnson
brettmjohnson earned 30 total points
ID: 12172618
In makefiles, whitespace matters.  I think you should learn some of the basics of make:

http://cygnus.uta.edu/cse6362/make.html

0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:ansi_c
ID: 12173135
i knew whitespace matters but then it just does not work.
I used vim and have set tabwidth to 4 and so the TABS just does not work as normal tab.

Tried setting the option off and it works now!
Thanks a lot..

Can you refer me to more makefile documentation? Preferably with macros, variables, etc..
0
 
LVL 45

Accepted Solution

by:
Kdo earned 20 total points
ID: 12174080

Hi anci_c,

There are differences in the implementation of Make().  Some are pretty subtle, some huge.  (Personally, I get a headache every time that I have to build a makefile just because I'm always stepping on these issues.)

But the basics are pretty close to universal.  You can download the Gnu Make documenation here:

http://www.gnu.org/software/make/manual/make.html


Good Luck,
Kent
0
 
LVL 3

Expert Comment

by:guynumber5764
ID: 12174922
The command must start with an actual TAB character.
0
 
LVL 4

Expert Comment

by:pankajtiwary
ID: 12176350
Hi ansi_c

You were just on the right track. Just a little modification. In make file every rule starts with a tab charecter.

Try this.

main1 : main1.o node.o
        cc -o main1 main1.o node.o
main1.o : main1.c node.h
        cc -c main1.c
node.o : node.c node.h
        cc -c node.c
clean : rm main1.o node.o

The error you are getting is because of that.

Hope this helps.
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

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…
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…
The goal of this video is to provide viewers with basic examples to understand and use pointers in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.

757 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now