Want to highlight a helpful answer? Upvote!

Did someone help you, or did an answer or User Tip resolve your issue? Upvote by selecting the upvote arrow. Your feedback helps others! Learn more about when to upvote >

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

"_main", referenced from:

im trying to migrate my project from windows to mac , when i use xcode to compile my code , i get the following error

Undefined symbols:
"_main", referenced from:
start in crt1.10.5.o
ld: symbol(s) not found
collect2: ld returned 1 exit status

please help

apple, Mac OS X (10.5.6)

Posted on Feb 15, 2009 8:27 PM

Reply
1 reply

Feb 15, 2009 11:15 PM in response to osama_abdelfattah

The short answer to your question is that the entry point to a Windows app is named 'WinMain', while the entry point to an OS X app is named 'main'. The linker message you reported just means that no main function was found, which is to be expected.

Of course you can't simply change the name of WinMain to main, since everything from the parameters to the API calls are going to be entirely different. If your Windows app is built on one of the libraries intended for an OS X port, a lot of the problems may be solved for you. Otherwise I think it's safe to say that the changes to WinMain are going to be the very least of your challenges.
Have you decided on whether to port to Carbon or Cocao? The choice might depend on whether your Windows program is written in "C" with direct calls to the Win32 API or written in C++ using MFC. I wish I could be of more help, but I've never moved a Windows program to OS X without a complete re-write.

All the very best of luck!!

"_main", referenced from:

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.