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

uaecasher

macrumors 65816
Original poster
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
 
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

It should be:

Code:
#include <stdio.h>
int main(void)
{
   printf("Goodbye, cruel world!\n");
   return 0;
}
 
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 😕
 
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 😕

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