help in C error

Discussion in 'Mac Programming' started by uaecasher, Mar 4, 2009.

  1. macrumors 65816

    uaecasher

    Joined:
    Jan 29, 2009
    Location:
    Stillwater, OK
    #1
    hello, I'm trying to build and go this code but it is giving me errors:

    Code:
    #include <stdio.h>
    int main()
    {
    	
     printf("GoodBye, crule world!\n");
    	return(0);
    }
    collect2: ld returned 1 exit status
     
  2. macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #2
    It should be:

    Code:
    #include <stdio.h>
    int main(void)
    {
       printf("Goodbye, cruel world!\n");
       return 0;
    }
     
  3. thread starter macrumors 65816

    uaecasher

    Joined:
    Jan 29, 2009
    Location:
    Stillwater, OK
    #3
    i found the problem, i had already a file in the same project which have main


    Code:
    #include <stdio.h>
    
    int main (int argc, const char * argv[]) {
        // insert code here...
        printf("Hello, World!\n");
        return 0;
    }
    
    here is the complete error:

    Line Location Tool:0: duplicate symbol _main in /Users/fahad/Documents/test/build/test.build/Debug/test.build/Objects-normal/i386/goodbye.o and /Users/fahad/Documents/test/build/test.build/Debug/test.build/Objects-normal/i386/main.o


    when i made a new project the 1st code worked why is xcode doing this :confused:
     
  4. macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #4
    Because you have two main functions defined.
     

Share This Page