• Welcome to Dark Bit Factory & Gravity.
 

expert question ;)

Started by Kirl, March 02, 2012

Previous topic - Next topic

0 Members and 0 Guests are viewing this topic.

Kirl

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:
www.kirl.nl
Challenge Trophies Won:

hellfire

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).
In the tree on the left open "linker" and "system".
On the right set the value "subsystem" to "console".


Challenge Trophies Won:

LittleWhite

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).
The demoscene will never die, never!

Kirl

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. :)
www.kirl.nl
Challenge Trophies Won:

hellfire

Quote from: Kirl on March 02, 2012
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?
Challenge Trophies Won:

ferris

QuoteIt 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.
http://iamferris.com/
http://youth-uprising.com/

Where the fun's at.
Challenge Trophies Won:

Kirl

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:
www.kirl.nl
Challenge Trophies Won: