LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 07-28-2004, 04:12 PM   #1
MattG1981
Member
 
Registered: Oct 2003
Posts: 32

Rep: Reputation: 15
Creating a Makefile with multiple header files


Here are my files that I have:

treeMain.c
tree.c
tree.h
queue.c
queue.h

Here is my Makefile:

Code:
all: Queue.o tree.o treeMain 

Queue.o: Queue.c
	gcc -c Queue.c
	
tree.o: tree.c
	gcc -c tree.c
	
treeMain: Queue.h Queue.o tree.h tree.o
	gcc -o treeMain Queue.o tree.o
	
splint:
	splint Queue.c tree.c treeMain.c
	
run:
	treeMain
	
clean:
	rm -f treeMain *.o
I am getting this error ....

gcc -o treeMain Queue.o tree.o
/usr/lib/gcc-lib/i386-redhat-linux/3.3.3/../../../crt1.o(.text+0x18): In function `_start':
: undefined reference to `main'
collect2: ld returned 1 exit status
make: *** [treeMain] Error 1

Can someone help me?
 
Old 07-28-2004, 04:26 PM   #2
itsme86
Senior Member
 
Registered: Jan 2004
Location: Oregon, USA
Distribution: Slackware
Posts: 1,246

Rep: Reputation: 56
Does one of either Queue.c or tree.c have a main() function in it?
 
Old 07-28-2004, 04:32 PM   #3
MattG1981
Member
 
Registered: Oct 2003
Posts: 32

Original Poster
Rep: Reputation: 15
treeMain.c has the main function in it
 
Old 07-28-2004, 04:47 PM   #4
itsme86
Senior Member
 
Registered: Jan 2004
Location: Oregon, USA
Distribution: Slackware
Posts: 1,246

Rep: Reputation: 56
You're don't have a build rule for treeMain.o that I see.

Maybe it should be:
Code:
treeMain: Queue.h Queue.o tree.h tree.o treeMain.c
	gcc -o treeMain Queue.o tree.o treeMain.c
 
Old 07-28-2004, 05:04 PM   #5
MattG1981
Member
 
Registered: Oct 2003
Posts: 32

Original Poster
Rep: Reputation: 15
that fixed it, thanks!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating Multiple Log Files koacamper Linux - Newbie 3 09-24-2005 07:24 PM
creating Makefile with multiple kernel module files b123coder Programming 0 12-26-2004 08:41 AM
How to write Makefile in 2.6 for including header files in another dir ? ashbalu Programming 0 10-19-2004 03:45 PM
c header files in linux in place of header files in windows? harun_acs Programming 1 03-17-2004 02:24 AM
[makefile] Do header files need to be set targets? chuanyung Programming 2 03-11-2004 09:22 PM


All times are GMT -5. The time now is 12:32 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration