Thread: Unknown error Xcode

  1. #1
    Registered User
    Join Date
    Jul 2011
    Posts
    1

    Question Unknown error Xcode

    I'm attempting at just writing a standard(very standard) application the code( C-programming compiled in Xcode) is error free except for one build error:

    ld: duplicate symbol _main in /Users/jasonbillings/Desktop/TestProject/build/TestProject.build/Debug/TestProject.build/Objects-normal/i386/YouWereBornIn.o and /Users/jasonbillings/Desktop/TestProject/build/TestProject.build/Debug/TestProject.build/Objects-normal/i386/main.o

    Command /Developer/usr/bin/gcc-4.2 failed with exit code 1

    Ive tried everything to get rid of the error I dont know if it's Xcode or me heres the code i wrote its very standard
    Code:
    #include <stdio.h>
    int subtract ( int this_year, int your_age );
    int main ( )
    {
    	int this_year ;
    	int your_age ;
    	char your_name ;
    	
    	printf( " Welcome player please enter your name " ) ;
    	scanf( "%s", &your_name ) ;
    	printf( "Welcome your_name now please enter your age" ) ;
    	scanf( "%d", &your_age) ;
    	printf( "Now please enter the year" ) ;
    	scanf( "%d", &this_year ) ;
    	printf( "your_name, was born in %d\n", subtract ( this_year, your_age) ) ;
    	getchar() ;
    }
    
    int subtract ( int this_year, int your_age )
    
    {
    return this_year - your_age ;
    }
    If any idea please post

  2. #2
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,909
    A quick Google search of "ld: duplicate symbol _main" turned up the following results:
    http://www.google.com/search?q="ld%3A+duplicate+symbol+_main"+xcode

    The first result is a Stack Overflow article that may help you out:
    iphone - Xcode duplicate symbol _main . - Stack Overflow

  3. #3
    Registered User
    Join Date
    Jun 2011
    Posts
    4,513
    You're trying to squeeze a string (aka an array of characters) into a single character.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Linking error in Xcode.
    By bhdavis1978 in forum C Programming
    Replies: 2
    Last Post: 03-19-2010, 02:32 PM
  2. Help, getting unknown error
    By halien in forum C Programming
    Replies: 11
    Last Post: 01-28-2010, 07:13 PM
  3. Error Loading Bitmaps in Xcode
    By hamishmcgee in forum C++ Programming
    Replies: 0
    Last Post: 12-01-2009, 03:11 PM
  4. unknown error
    By pktcperlc++java in forum C++ Programming
    Replies: 8
    Last Post: 12-29-2004, 06:08 PM

Tags for this Thread