Solved

undefined reference to `main'

Posted on 2004-09-25
4
1,583 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
[X]
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
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
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.
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.

729 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