I've seen this discussed in various topics but none are active for replies so I'm posting here.
I experienced this link error using Eclipse IDE for C/C++ Developers on Windows 7. Under Properties I had this configuration
C/C++ Build Tool Chain Editor Current toolchain: MinGW GCC
C/C++ Build Tool Chain Editor Current Builder: CDT Internal Builder
I used the IDE to create the Class files (.cpp aand .h). The mistake I made, which caused my error was I put main() inside the automatically generated block - namespace std { ... }. Outside, I don't get the "undefined reference to `WinMain@16'" error. Easy to see now why it didn't find the entry point.
#include "A.h"
namespace std {
A::A() {
// TODO Auto-generated constructor stub
}
A::~A() {
// TODO Auto-generated destructor stub
}
int main( int argc, char** argv ){ // << inside namespace std causes the error
return 0;
}
Removing the namespace std {will fix this issue. The compiler looks for int main(int, char**) to run. You are supplying it with int std::main(int, char**).
Most likely you meant usingnamespace std; rather than namespace std {. The first will allow you to access members of std, but the second will run all your code as a member of std.