Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » make: *** [main] Error 1
make: *** [main] Error 1 [message #783606] Thu, 26 January 2012 04:00 Go to next message
Jamie Gardiner is currently offline Jamie GardinerFriend
Messages: 4
Registered: January 2012
Junior Member
hey,

Does any one know what this means make: ***[main] Error 1? I have been trying to fix this issue over the last 2-3 days but I am unable to make any progress. I only have one ccp file in the program, but I am still unable to fix the issue.


Very frustrating.
  • Attachment: main.cpp
    (Size: 2.39KB, Downloaded 239 times)
Re: make: *** [main] Error 1 [message #783676 is a reply to message #783606] Thu, 26 January 2012 08:02 Go to previous messageGo to next message
Jamie Gardiner is currently offline Jamie GardinerFriend
Messages: 4
Registered: January 2012
Junior Member
The error message is actually Undefined symbols:"_main", referenced from: start in crt1.10.6.old: symbol(s) not found. I am still at odds
Re: make: *** [main] Error 1 [message #783700 is a reply to message #783676] Thu, 26 January 2012 08:54 Go to previous messageGo to next message
HagenFriend
Messages: 90
Registered: April 2010
Member
On 1/26/2012 9:02 AM, Jamie Gardiner wrote:
> The error message is actually Undefined symbols:"_main", referenced
> from: start in crt1.10.6.old: symbol(s) not found. I am still at odds

The C runtime needs to link to a function "main". But you don't hae one
if you use a CPP file.

C++ does make "name mangling" to allow several functions with the same
name differing only in return and parameter types.

Look up the explanation for the
extern "C" { ... }
Syntax construct and apply it to the "main" function.


....or just rename your *.cpp file to *.c
Re: make: *** [main] Error 1 [message #783736 is a reply to message #783700] Thu, 26 January 2012 10:51 Go to previous messageGo to next message
Jamie Gardiner is currently offline Jamie GardinerFriend
Messages: 4
Registered: January 2012
Junior Member
Thanks Hagen, I just have a conflicting types error on line 13 now, but should be able to figure this out. Thanks again.
Re: make: *** [main] Error 1 [message #783782 is a reply to message #783736] Thu, 26 January 2012 12:54 Go to previous message
HagenFriend
Messages: 90
Registered: April 2010
Member
On 1/26/2012 11:51 AM, Jamie Gardiner wrote:
> Thanks Hagen, I just have a conflicting types error on line 13 now, but
> should be able to figure this out. Thanks again.

Another catch: Just naming a _file_ "main" means nothing to the actual
defined symbols. C/C++ is not Java (and even there you need to name
methods as expected by other components).

You _do_ need a function with the name "main" to please the linker. :-)

"main" needs a signature similar to "int main(int argc, char *argv[])"
for the C runtime to link to it.

I'd recommend to only wrap this main as an "entry point routine" in an
'extern "C"' declaration and then call your actual work function from it.




[Sorry for the off-topic post: all of this is C/C++ 101, and has nothing
to do at all with Eclipse or CDT.]
Previous Topic:C++ program built successfully but does not run
Next Topic:namespace name and headers not recognized
Goto Forum:
  


Current Time: Fri Dec 19 16:03:45 GMT 2014

Powered by FUDForum. Page generated in 0.01940 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software