Solved

undefined reference to `main'

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Adjust Mfcapp 29 172
Global Keyboard Hooks Blocked 4 81
gdb doesn't stop on breakpoint 2 93
Memory going from 12gb to 64gb or 96gb. worth it? 15 203
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.

839 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