Solved

undefined reference to `main'

Posted on 2004-09-25
4
1,560 Views
Last Modified: 2008-01-09
hi all
i made 3 files and made a makefile for them  but everytime i try to make myprogram i get this error:

 make myprogram
gcc -o myprogram point.o rectangle.o testRectangle.o
/usr/lib/gcc-lib/i386-redhat-linux/3.2.2/../../../crt1.o(.text+0x18): In function `_start':
../sysdeps/i386/elf/start.S:77: undefined reference to `main'
collect2: ld returned 1 exit status
make: *** [myprogram] Error 1

what is the fault im doing?  i dont have main

thanks
0
Comment
Question by:kimos123
  • 2
  • 2
4 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 12152857
You need main.
Where does your program start?
0
 

Author Comment

by:kimos123
ID: 12153935
this is my  makefile
---------------------------

# ’myprogram’ is built from
# point.c rectangle.c and testRectangle.c

CC = gcc
CFLAGS = -Wall
OBJS = point.o rectangle.o testRectangle.o

point.o: point.c
      $(CC) $(CFLAGS) -c point.c

rectangle.o: rectangle.c
      $(CC) $(CFLAGS) -c rectangle.c

testRectangle.o: testRectangle.c
      $(CC) $(CFLAGS) -c testRectangle.c

main.o: main.c
      $(CC) $(CFLAGS) -c main.c

myProg: $(OBJS)
      $(CC) -o myProg $(OBJS)

-----------------------------------------
and this is my main.c file


#include "testRectangle.h"
 Rectangle rec,bol,inter;
 Point pt , p1,p2,b1,b2;

main(void){

pt=makePoint(3,-12);

p1=makePoint(2,2);
p2=makePoint(5,4);

b1=makePoint(4,1);
b2=makePoint(6,6);
   
bol=makeRectangle(b1,b2);

 showPoint(pt);
rec=makeRectangle(p1,p2);
showRectangle(rec);
inter=intersection(rec,bol);

testArea();
 testisEmpty();
testIntersection(inter);
      exit(0);

       }
------------------------

using the following command  :   make myProg   give me this error

C:\gcc-2.95.2\bin>make myProg
gcc -Wall -c testRectangle.c
gcc -o myProg point.o rectangle.o testRectangle.o
..\lib\gcc-lib\i386-mingw32\2.95.2\..\..\..\..\i386-mingw32\lib\libmingw32.a(main.o)(.text+0x8e): undefined reference to `WinMain@16'
make: *** [myProg] Error 1

any ideas?
0
 
LVL 84

Accepted Solution

by:
ozo earned 50 total points
ID: 12153945
OBJS = main.o point.o rectangle.o testRectangle.o
0
 

Author Comment

by:kimos123
ID: 12154185
thanks ozo its working now
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

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

746 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

12 Experts available now in Live!

Get 1:1 Help Now