New To Mac-Forums?

Welcome to our community! Join the discussion today by registering your FREE account. If you have any problems with the registration process, please contact us!

Get your questions answered by community gurus Advice and insight from world-class Apple enthusiasts Exclusive access to members-only contests, giveaways and deals

Join today!

 
Start a Discussion
 

Mac-Forums Brief

Subscribe to Mac-Forums Brief to receive special offers from Mac-Forums partners and sponsors

Join the conversation RSS
OS X - Operating System General OS operation information and support

Error from Xcode making no sense to me????


Post Reply New Thread Subscribe

 
Thread Tools
zzwd

 
Member Since: Dec 21, 2009
Posts: 1
zzwd is on a distinguished road

zzwd is offline
I wanna study the C++ in XCode. After installing, I just inputted a following sample code,

#include <iostream>
using namespace std;

int main()
{
int iterations = 0;
bool continue_loop = true;
while ( continue_loop != false )
{
iterations++;
cout << "the while loop has executed "
<< iterations << " times\n";
if ( iterations == 5 )
continue_loop = false;
}
return 0;
}

but the XCode said "it is fail", the reason is
"duplicate symbol _main in /Users/roger/Documents/Try/build/Try.build/Debug/Try.build/Objects-normal/x86_64/Try.o and /Users/roger/Documents/Try/build/Try.build/Debug/Try.build/Objects-normal/x86_64/main.o"

so please help me, is it my mistake to install the xcode or open a wrong file, or some reasons.

Thank you very much..........
QUOTE Thanks
Raz0rEdge

 
Raz0rEdge's Avatar
 
Member Since: Jul 17, 2009
Location: MA
Posts: 7,744
Raz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant future
Mac Specs: 27" i7 iMac, 24" iMac, 13" Macbook Air, iPhone 5 & 5S, iPod Nano 7th Gen, iPad 2 16GB WiFi, iPad 3

Raz0rEdge is offline
The error code actually makes perfect sense, you have 2 "main" functions which isn't allowed. Every program you create can only have one main function, because that's the function that is run FIRST when the application is run. Looks like you have possibly two files called "Try.cpp" and "main.cpp"??

How did you create the XCode project for your test?

Regards
QUOTE Thanks

Post Reply New Thread Subscribe


« I lost my data | logitech bluetooth mouse not found on restarting Mac Pro »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread
Thread Starter
Forum
Replies
Last Post
Xcode baltrx Switcher Hangout 3 10-22-2008 09:50 AM
Xcode Help! Kathe OS X - Development and Darwin 1 09-21-2008 03:57 PM
Carbon framework on XCode Rafi Shalom OS X - Development and Darwin 1 04-17-2008 02:14 PM
Xcode? y0itzr0 OS X - Operating System 5 04-08-2008 07:57 PM
Results in XCode urlugal OS X - Development and Darwin 1 04-07-2008 11:18 AM

All times are GMT -4. The time now is 04:04 AM.

Powered by vBulletin
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
X

Welcome to Mac-Forums.com

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!


(4 digit year)

Already a member?