Author Topic: expert question ;)  (Read 5171 times)

0 Members and 1 Guest are viewing this topic.

Offline Kirl

  • Senior Member
  • Pentium
  • ********
  • Posts: 1217
  • Karma: 230
    • View Profile
    • Homepage
expert question ;)
« 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:

Code: [Select]
#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:

Offline hellfire

  • Sponsor
  • Pentium
  • *******
  • Posts: 1294
  • Karma: 466
    • View Profile
    • my stuff
Re: expert question ;)
« Reply #1 on: March 02, 2012 »
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:

Offline LittleWhite

  • Senior Member
  • Amiga 1200
  • ********
  • Posts: 418
  • Karma: 31
  • It's me!
    • View Profile
Re: expert question ;)
« Reply #2 on: March 02, 2012 »
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!

Offline Kirl

  • Senior Member
  • Pentium
  • ********
  • Posts: 1217
  • Karma: 230
    • View Profile
    • Homepage
Re: expert question ;)
« Reply #3 on: March 02, 2012 »
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:

Offline hellfire

  • Sponsor
  • Pentium
  • *******
  • Posts: 1294
  • Karma: 466
    • View Profile
    • my stuff
Re: expert question ;)
« Reply #4 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:

Offline ferris

  • Pentium
  • *****
  • Posts: 841
  • Karma: 84
    • View Profile
    • Youth Uprising Home
Re: expert question ;)
« Reply #5 on: March 02, 2012 »
Quote
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.
http://iamferris.com/
http://youth-uprising.com/

Where the fun's at.
Challenge Trophies Won:

Offline Kirl

  • Senior Member
  • Pentium
  • ********
  • Posts: 1217
  • Karma: 230
    • View Profile
    • Homepage
Re: expert question ;)
« Reply #6 on: March 02, 2012 »
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: