about gcc errors

Asked by prasad.ram

sir i write a program in c for which it prints required date and month of year which is given by the user so i divide my program into two parts one is calculating(name is cal.c) and another one is for printing the month (name is trash.c) in this program i did not use main() and i include this(trash.c) in cal.c but when i am compiling trash.c it gave me error which is given below what is the error and how could it remove
"ramu@ramki:~$ gcc trash.c
/usr/lib/gcc/i686-linux-gnu/4.4.5/../../../../lib/crt1.o: In function `_start':
(.text+0x18): undefined reference to `main'
collect2: ld returned 1 exit status"
please tell me

Question information

Language:
English Edit question
Status:
Answered
For:
Ubuntu gcc-defaults Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
mycae (mycae) said :
#1

You have requested that gcc make a binary (executable file) without providing it with a main function. you MUST have a main function.

Revision history for this message
mycae (mycae) said :
#2

If you wish to have two separate files, you have to specify that you do *not* want a binary, but just a compiled object (.o) file.

use the "-c" option to do this

ie

gcc test.cpp -c -o test.o

Can you help with this problem?

Provide an answer of your own, or ask prasad.ram for more information if necessary.

To post a message you must log in.