Farmer
Farmer

Reputation: 10983

Problem while Debugging a C++ project using Visual Studio 2010

I'm having two errors everytime I try to debug a simple project in Visual Studio 2010.

Error   1   error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup   C:\Users\Fighter\Documents\C++\Point\Point\MSVCRTD.lib(crtexe.obj)  Point

Error   2   error LNK1120: 1 unresolved externals   C:\Users\Fighter\Documents\C++\Point\Debug\Point.exe    1   1   Point

this is a simple code I'm using to try my program in VS :

class Point

{
private:
int x;
int y;

};

The problem is that this thing works great in Code::Blocks but whith VS it gives me those errors.

What's the problem here.

Thanks

Upvotes: 0

Views: 188

Answers (4)

John Dibling
John Dibling

Reputation: 101456

Every C++ program must have a function called main(). It can take one of two forms:

  1. int main()
  2. int main(int argc, char* argv[])

Implement one of these (probably the first), and recompile.

Upvotes: 0

wallyk
wallyk

Reputation: 57784

You need to define a function named main() or main(int argc, char **argv).

Upvotes: 0

Xavier V.
Xavier V.

Reputation: 6458

The compiler says to you that he wants you to define an entry point to your application. (a.k.a a function main.)

Upvotes: 0

Macke
Macke

Reputation: 25690

Your program needs a main() function to be valid.

int main(int argc, char* argv[]) 
{
    Point p;
    return 0;
} 

Upvotes: 2

Related Questions