Solved

undefined reference to `main'

Posted on 2004-09-25
4
1,578 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

Suggested Solutions

Title # Comments Views Activity
Problem in finding output of a program 11 108
UPD maximums on Red Hat 6 125
convert char array to number in c 5 91
Assignment from incompatible pointer type? 2 40
An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
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 opening and writing to files in the C programming language.
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.

726 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