Dark Bit Factory & Gravity
PROGRAMMING => C / C++ /C# => Topic started by: Kirl on March 02, 2012
-
Right so I'm sitting down for C++ after a bit, with a book at my side but I can't get the first example to work. :-[
So I make a new project "first"
and add "first.cpp" with the following code:
#include <iostream>
int main()
{
using namespace std;
cout << "This sux donkey balls!!";
cout << endl;
cout << "skool me!" << endl;
return 0;
}
compiler says:
1>MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup
1>C:\Users\Public\Documents\Programming\C++\first\Debug\first.exe : fatal error LNK1120: 1 unresolved externals :crutches:
-
Visual C++ distinguishes console application (which open as a command prompt) and windows application (which create their own window).
The first one assumes a "main()" function while the latter one assumes a "WinMain()" function (which is not available right now and that's what the linker is trying to tell you).
So all you need to do is to configure your project to be a console application.
Go to the project properties page (this one (http://www.viva64.com/blog/en/wp-content/uploads/2010/03/habr-07-1.png)).
In the tree on the left open "linker" and "system".
On the right set the value "subsystem" to "console".
-
Totally agree with Hellfire.
(Actually I hate these kind of Microsoft's fancy stuff).
The WinMain accept some special Microsoft types (Handle to commande line / parent Window).
-
Thanks Hellfire, hopefully I won't run into too many VC++ particularities.
When I'm a little bit more comfortable I guess editing files in a seperate text editor like notepad++ might be preferable. Or some sort of barebones IDE, all I need is a text editor and a compile button. :)
-
I guess editing files in a seperate text editor like notepad++ might be preferable.
Or some sort of barebones IDE, all I need is a text editor and a compile button. :)
It just takes some time to realize that the intellisense is actually helpful :)
Are you using the Express edition?
-
It just takes some time to realize that the intellisense is actually helpful :)
Especially with C#; half the code is written with Tab and Enter :D It's simply wonderful.
-
Yes, I'm using VC++ 2010 Express.
Flash has some sort of auto-complete as well, but I fail to make use of that functionality at all! :whack: