Mac Error found when compiling

CuteBoA

macrumors newbie
Original poster
Mar 12, 2010
21
0
Line Location Tool:0: Command /Developer/usr/bin/g++-4.0 failed with exit code 1


Line Location Tool:0: duplicate symbol _main in /Users/indahandriani/Desktop/a/build/a.build/Debug/a.build/Objects-normal/i386/a.o and /Users/indahandriani/Desktop/a/build/a.build/Debug/a.build/Objects-normal/i386/main.o


hello, anyone know whats the problem with that? and what should i do with that?
thank you!
 

Reason077

macrumors 68020
Aug 14, 2007
2,188
679
The problem is that you are compiling/linking two different files which both have a main() function. There can only be one main() in your application.
 

CuteBoA

macrumors newbie
Original poster
Mar 12, 2010
21
0
That answer doesn't really mean much. Are you compiling on the command line or from within Xcode? If you are compiling from within Xcode it already has a default main() function defined so you don't need to define your own (assuming you chose the correct project template).
im still pretty confused with how Xcode works.. what is command line?
usually i write my program in .cpp file, and then i press build and debug..
so what does that meann?
i never had this kind of problem before..

i usually compile the one with. xcodeproj
 

CuteBoA

macrumors newbie
Original poster
Mar 12, 2010
21
0
OK, we now understand you are using Xcode.

Could you tell us how many files end in either ".c", ".cp" or ".cpp". As well as their names!
aaa.cpp
main.cp
TApplication.cp
TCarbonEvent.cp
TEventHandler.cp
TNib.cp
TWindow.cp

thats it!
 

lloyddean

macrumors 65816
May 10, 2009
1,001
16
Des Moines, WA
The easiest way to help is to have you create a new project with the setting you see below. Name the project whatever seems appropriate to you.

Screen shot 2010-04-05 at 3.16.35 PM.png

Once the project is open you'll see it contains a file "main.cpp".

Screen shot 2010-04-05 at 3.17.45 PM.png

Open "main.cpp" replacing it's contents with yours.

Compile, run and enjoy!!!
 

CuteBoA

macrumors newbie
Original poster
Mar 12, 2010
21
0
The easiest way to help is to have you create a new project with the setting you see below. Name the project whatever seems appropriate to you.

View attachment 220936

Once the project is open you'll see it contains a file "main.cpp".

View attachment 220937


Compile, run and enjoy!!!
i cant seem to find how to make mine like the first picture..
what should i do to make that box appear?

 

lloyddean

macrumors 65816
May 10, 2009
1,001
16
Des Moines, WA
You are running an older version of Xcode, so select "Command Line Utility" from the list on the left side of that Dialog-Window. The content on the right side may change allowing you to choose a C++ type project, which is what you want!
 

CuteBoA

macrumors newbie
Original poster
Mar 12, 2010
21
0
You are running an older version of Xcode, so select "Command Line Utility" from the list on the left side of that Dialog-Window. The content on the right side may change allowing you to choose a C++ type project, which is what you want!
it works now!! thank you so much for helping me!:D