undefined reference to 'main'

undefined reference to 'main'

Post by Doug Laidla » Fri, 17 Jan 2003 22:20:27



I am using Mandrake Linux 9.0 with gcc 3 series (I think.)

Twice when compiling from source I got the error:

undefined reference to 'main'

I can't see tht reference in the Makefile.

This has been discussed extensively from a programming point of view, but is
there anything that an end user can do about it, such as a switch?  If it
has happened twice in a row, it suggests that my system is somehow at
fault.

(Yes, I know I should be using RPMs, but they aren't always available.)

Thanks for any help,

Doug.

 
 
 

undefined reference to 'main'

Post by Tony Curti » Fri, 17 Jan 2003 23:49:19


>> On Fri, 17 Jan 2003 00:20:27 +1100,

> I am using Mandrake Linux 9.0 with gcc 3 series (I
> think.)  Twice when compiling from source I got the
> error:
> undefined reference to 'main'
> I can't see tht reference in the Makefile.

"main" is the function that starts the actual program.  If
there's no main() then the program cannot link into an
executable.  It doesn't have anything to do with the
Makefile (per se).  There appears to be something missing
from the source code you are compiling, or you
misunderstood what to do with the code.

hth
t

 
 
 

undefined reference to 'main'

Post by John Winte » Sat, 18 Jan 2003 02:38:49




Quote:>I am using Mandrake Linux 9.0 with gcc 3 series (I think.)

>Twice when compiling from source I got the error:

>undefined reference to 'main'

When compiling what from source?  It sounds like you have an incomplete
program.

Quote:>I can't see tht reference in the Makefile.

There wouldn't be.  The error will actually be arising at the link
stage.  Each program needs a function called "main" which is where the
program execution starts.  It sounds like your program doesn't have
one.

Quote:>This has been discussed extensively from a programming point of view, but is
>there anything that an end user can do about it, such as a switch?

Generally speaking, end users don't compile programs (unless you mean
end users of the compiler).  It's intrinsically a programming problem.

Quote:>If it
>has happened twice in a row, it suggests that my system is somehow at
>fault.

It suggests that the source code you're compiling is at fault.

Tell us what you're trying to compile and how and we may be able to help.

John
--
The Linux Emporium - the source for Linux in the UK
See http://www.linuxemporium.co.uk/

We had a woodhenge here once but it rotted.

 
 
 

undefined reference to 'main'

Post by Doug Laidla » Sat, 18 Jan 2003 12:48:50





>>I am using Mandrake Linux 9.0 with gcc 3 series (I think.)

>>Twice when compiling from source I got the error:

>>undefined reference to 'main'

> When compiling what from source?  It sounds like you have an incomplete
> program.

>>I can't see tht reference in the Makefile.

> There wouldn't be.  The error will actually be arising at the link
> stage.  Each program needs a function called "main" which is where the
> program execution starts.  It sounds like your program doesn't have
> one.

>>This has been discussed extensively from a programming point of view, but
>>is there anything that an end user can do about it, such as a switch?

> Generally speaking, end users don't compile programs (unless you mean
> end users of the compiler).  It's intrinsically a programming problem.

>>If it
>>has happened twice in a row, it suggests that my system is somehow at
>>fault.

> It suggests that the source code you're compiling is at fault.

> Tell us what you're trying to compile and how and we may be able to help.

> John

Thanks John.   I had this recently with Festival, a text-to-speech program I
compiled successfully under Mandrake 8.2, but which refused to compile
under 9.0.  I posted about it, but now I can't find the reference.  That is
what I meant by "twice in a row."  Perhaps I was just unlucky.  My latest
failure is with  celestia v. 2.5, an OpenGL astronomy program
(http://www.shatters.net/celestia/)

Doug.

Doug.

 
 
 

undefined reference to 'main'

Post by Erik de Castro Lop » Sat, 18 Jan 2003 13:27:04



> Thanks John.   I had this recently with Festival, a text-to-speech program I
> compiled successfully under Mandrake 8.2, but which refused to compile
> under 9.0.  I posted about it, but now I can't find the reference.  That is
> what I meant by "twice in a row."  Perhaps I was just unlucky.  My latest
> failure is with  celestia v. 2.5, an OpenGL astronomy program
> (http://www.shatters.net/celestia/)

This may not be the answer you want to hear, but if you are
running Debian, it is possible to apt-get Debian packages
for both Festival and Celestia from a Debian mirror.

Using Debian means that you spend less time trying to compile
software and more time using it.

Erik
--
+-----------------------------------------------------------+

+-----------------------------------------------------------+
"If you don't know what you need Windows NT for, you don't need it."
  - Bill Gates

 
 
 

undefined reference to 'main'

Post by Doug Laidla » Sat, 18 Jan 2003 17:23:10




>> Thanks John.   I had this recently with Festival, a text-to-speech
>> program I compiled successfully under Mandrake 8.2, but which refused to
>> compile
>> under 9.0.  I posted about it, but now I can't find the reference.  That
>> is
>> what I meant by "twice in a row."  Perhaps I was just unlucky.  My latest
>> failure is with  celestia v. 2.5, an OpenGL astronomy program
>> (http://www.shatters.net/celestia/)

> This may not be the answer you want to hear, but if you are
> running Debian, it is possible to apt-get Debian packages
> for both Festival and Celestia from a Debian mirror.

> Using Debian means that you spend less time trying to compile
> software and more time using it.

> Erik

Thanks Erik.  I am using Mandrake 9, a RPM system.  There is an RPM for
Festival at least, but I am on a dialup modem, and the site doesn't support
resume.

I installed a minimal Debian package, but it had to download the rest, and I
have a Linmodem.

Doug.

 
 
 

1. undefined reference to 'main', In function '__uClibc_main'..

DEAR YOU.

I'm trying to develop an apllication on the ARM7TDMI  board using
uClinux-dist and arm-elf-toolchain.
I found the below error message.

I looked at the /uClibc/libc/misc/internals/__uClibc_main.c file and looked
for the "extern void main(int argc,void *argv,void *envp);" and
"exit(main(argc, argv, envp));"
But I couldn't know where the function "main(argc, argv, envp)" was defined.

Please beg your advice.
Have a Happy day.

/usr/local/arm-elf/lib/libc.a(__uClibc_main.o): In function `__uClibc_main':
__uClibc_main.o(.text+0xac): undefined reference to `main'
__uClibc_main.o(.text+0xbc): undefined reference to `_fini'
__uClibc_main.o(.text+0xc4): undefined reference to `_init'
collect2: ld returned 1 exit status
make[2]: *** [obj/arm-elf/libixml.so] Error 1
make[1]: *** [all] Error 2
make: *** [upnp] Error 2

2. Incredible developments in Italy regarding business software

3. [3rd RESENT] kill dentry<->fh conversation code duplication

4. undefined reference to `pw_crypt',undefined reference to `spw_unpack'

5. TRANTOR ll'el-SCSI adaptors on X86

6. Porting to Linux: crt1.o and "undefined reference to `main'"

7. Can Linux Feed Multiple Video Chips Locally to support several Video Monitors ?

8. /usr/lib/crt1.o(.text+0x69): undefined reference to `main'

9. drivers/block/block.o: In function `rd_blkdev_pagecache_IO' and `rd_make_request': undefined reference to `bio_size'

10. Can't seem to fix `undefined reference to `stat'' and `undefined reference to `atexit''

11. undefined reference to 'assert'

12. linker error: 'undefined reference'