• Welcome to Valhalla Legends Archive.
 

I have this error i cant get Rid of

Started by MysT_DooM, May 30, 2004, 05:57 PM

Previous topic - Next topic

MysT_DooM

Now im not making like a real high tech program, i was just foolin around makin the "Hello World" program thing and this error comes up:

LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16
Debug/delte this.exe : fatal error LNK1120: 1 unresolved externals

~~~~~~~~~~~
This is my code for the Hello program:

///Hello

#include <iostream.h>

int main()

{

   cout <<"Hello Computer User\n\a";

   return 0;

}

~~~~~~~~~~~~~~~~~~
U see theres nuttin wrong wit my code...
WATS WRONG


vb6, something about that combination of numbers and letters is sexy

K

#1
you have the project setup as a windows application, not a console application.

your code is (almost) fine, but this is better:

// the new c++ stl headers don't have .h at the end
// and everything is inside the std namespace to prevent
// naming conflicts
#include <iostream>

// but we can just use the namespace since this is
// a small program with no conflicts.
using namespace std;

int main()
{
  // endl is a special object that not only prints a \r\n character
  // but flushes the stream so that the text you wrote is written
  // right away, which doesn't always happen.
  cout << "Hello Computer User" << endl;

 return 0;
}


but don't sweat that too much.  here's how to fix your problem:

(assuming visual c++)

go to project properties, click on LINKER, then on SYSTEM and change the SUBSYSTEM property from "Windows (/SUBSYSTEM:WINDOWS)" to "Console (/SUBSYSTEM:CONSOLE)"  You'll need to do this for both DEBUG and RELEASE configurations if you plan on changing the configuration.

Then your program should compile fine!.

Eibro

#2
You can also use the VC++ specific directive
#pragma comment(linker, "/SUBSYSTEM:CONSOLE" )
Eibro of Yeti Lovers.