Solved

Make

Posted on 2004-09-28
8
253 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
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 
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
 

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

ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Having a file "symlink" to a memory location (Windows) 6 174
Compile VxWorks Toronado project under Visual Studio 11 200
Inorder binary search tree 5 166
C++ vs C compilers 13 159
An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
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 opening and writing to files in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.

809 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