Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

uaecasher

macrumors 65816
Original poster
Jan 29, 2009
1,289
0
Stillwater, OK
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
 

uaecasher

macrumors 65816
Original poster
Jan 29, 2009
1,289
0
Stillwater, OK
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:
 

Cromulent

macrumors 604
Oct 2, 2006
6,817
1,102
The Land of Hope and Glory
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:

Because you have two main functions defined.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.