Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

undefined reference to `main'

Posted on 2004-09-25
4
Medium Priority
?
1,591 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 85

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 85

Accepted Solution

by:
ozo earned 200 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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…
This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.
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.

971 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