I have most bizarre and probably simple to solve problem but it’s driving me crazy.
I’m using XCode 4, I’ve started with an empty project added a new file main.cpp containing:
#include <iostream>
using namespace std;
int main(int argc, const char * argv[]) {
cout << "Hi There!" << endl;
}
Then I added a target called main and added main.cpp to it’s sources and compiled and run to be greeted with:
Hello, World!
In return.
Why is XCode adding and compiling it’s own main function and how to I tell it to use mine?
It also compiles and runs successfully with an empty main.cpp.
Thanks.
First try cleaning and rebuilding.
If that doesn’t work sounds like there is another file with a main in it that is being included in the build.
In the Project File, go into the “Build Phases” tab, and see what is listed under “Compile Sources”. The source of your problem might be there.