Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Make

Posted on 2004-09-28
8
254 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
Easy, flexible multimedia distribution & control

Coming soon!  Ideal for large-scale A/V applications, ATEN's VM3200 Modular Matrix Switch is an all-in-one solution that simplifies video wall integration. Easily customize display layouts to see what you want, how you want it in 4k.

 
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:
Kent Olsen 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

Connect further...control easier

With the ATEN CE624, you can now enjoy a high-quality visual experience powered by HDBaseT technology and the convenience of a single Cat6 cable to transmit uncompressed video with zero latency and multi-streaming for dual-view applications where remote access is required.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
C: GetDiskFreeSpaceEx() for default drive 14 114
Inorder binary search tree 5 173
How to set environment variables in C 2 86
Arduino EDI - Programming language 3 103
Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
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 while-loops in the C programming language.

860 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