PDA

View Full Version : help in C error




uaecasher
Mar 4, 2009, 11:02 AM
hello, I'm trying to build and go this code but it is giving me errors:

#include <stdio.h>
int main()
{

printf("GoodBye, crule world!\n");
return(0);
}

collect2: ld returned 1 exit status



Cromulent
Mar 4, 2009, 11:15 AM
hello, I'm trying to build and go this code but it is giving me errors:

#include <stdio.h>
int main()
{

printf("GoodBye, crule world!\n");
return(0);
}collect2: ld returned 1 exit status

It should be:

#include <stdio.h>
int main(void)
{
printf("Goodbye, cruel world!\n");
return 0;
}

uaecasher
Mar 4, 2009, 11:25 AM
i found the problem, i had already a file in the same project which have main


#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
Mar 4, 2009, 12:10 PM
i found the problem, i had already a file in the same project which have main


#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.