Error found when compiling

Discussion in 'Mac Programming' started by CuteBoA, Apr 5, 2010.

  1. CuteBoA macrumors newbie

    Joined:
    Mar 12, 2010
    #1
    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!
     
  2. lloyddean macrumors 6502a

    Joined:
    May 10, 2009
    Location:
    Des Moines, WA
    #2
    Are you compiling from the command line, or an Xcode project file?
     
  3. CuteBoA thread starter macrumors newbie

    Joined:
    Mar 12, 2010
    #3
    .cpp one..
     
  4. Reason077 macrumors 68000

    Reason077

    Joined:
    Aug 14, 2007
    #4
    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.
     
  5. CuteBoA thread starter macrumors newbie

    Joined:
    Mar 12, 2010
    #5
    how can I fixed it then? HELP!
     
  6. lloyddean macrumors 6502a

    Joined:
    May 10, 2009
    Location:
    Des Moines, WA
    #6
    Please tell us how you are compiling your source files?
     
  7. Cromulent macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #7
    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).
     
  8. CuteBoA thread starter macrumors newbie

    Joined:
    Mar 12, 2010
    #8
    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
     
  9. lloyddean macrumors 6502a

    Joined:
    May 10, 2009
    Location:
    Des Moines, WA
    #9
    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!
     
  10. CuteBoA thread starter macrumors newbie

    Joined:
    Mar 12, 2010
    #10
    aaa.cpp
    main.cp
    TApplication.cp
    TCarbonEvent.cp
    TEventHandler.cp
    TNib.cp
    TWindow.cp

    thats it!
     
  11. lloyddean macrumors 6502a

    Joined:
    May 10, 2009
    Location:
    Des Moines, WA
    #11
    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!!!
     
  12. CuteBoA thread starter macrumors newbie

    Joined:
    Mar 12, 2010
    #12
    i cant seem to find how to make mine like the first picture..
    what should i do to make that box appear?

    [​IMG]
     
  13. lloyddean macrumors 6502a

    Joined:
    May 10, 2009
    Location:
    Des Moines, WA
    #13
    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!
     
  14. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #14
  15. CuteBoA thread starter macrumors newbie

    Joined:
    Mar 12, 2010
    #15
    it works now!! thank you so much for helping me!:D
     

Share This Page