ID:275058
 
well i just started leanring C++ and im coding with Visual C++ and i did this
#include <iostream.h>
int main()
{
cout<<"Hello world!";
return 0;
}

it works fine, when i make a Win32 concole application, but when its jsut a win32 application it compiles fine but when i run it and make it an exe it gives me these errors
--------------------Configuration: Tset - Win32 Debug--------------------
Compiling...
test.cpp
Linking...
LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16 Debug/Tset.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

can anyone help?
LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16
Debug/Tset.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
can anyone help?

It's trying to compile a Windows application instead of a dos one. When you create a project you need to make a Win32 console app instead of a Win32 application.
In response to Theodis
but i want it a windows application, how do i do that?
In response to FeLeS_CeLeR
FeLeS_CeLeR wrote:
but i want it a windows application, how do i do that?

You can't use cout or main(). You need to have a WinMain() function which needs to be defined in a certain way. Look it up in the reference or over at msdn.microsoft.com . This is just for getting it to compile there is still a lot of work you need to do to build a form, menu, objects, ect. If you don't know how to do this it would probably be best to get a book on programming windows applications using the Windows APIs.
In response to Theodis
thanks, ill look into that, seems like i used my other key when posting though heh
In response to Magnus VI
In my programming class. All we make is console programs. But right now were not gonna do Win32 Apps. And if you don't want to use "int main()" you could also use "void main()" instead. This could eliminate the use of using return 0;! Very handy for me. Since I forget things like that!

-GDT
In response to GoodDoggyTreat
GoodDoggyTreat wrote:
In my programming class. All we make is console programs. But right now were not gonna do Win32 Apps. And if you don't want to use "int main()" you could also use "oid main()" instead. This could eliminate the use of using return 0;! Very handy for me. Since I forget things like that!

-GDT

The problem with the void main() definition is that it isn't defined as a valid entry point in ANSI C. So that definition might not work on all C compilers.
In response to Theodis
Yeah I know that. But my school has the good fortune enough to afford 326 Microsoft Visual Studio C++. Or should I say, they had the good fortune to have one disc of Microsoft Visual Studio C++, one CD Burner, and a load of blank CD-Rs from Wal-Mart!

-GDT
In response to GoodDoggyTreat
GoodDoggyTreat wrote:
Yeah I know that. But my school has the good fortune enough to afford 326 Microsoft Visual Studio C++. Or should I say, they had the good fortune to have one disc of Microsoft Visual Studio C++, one CD Burner, and a load of blank CD-Rs from Wal-Mart!

-GDT

Yeah but Borlands C++ compiler is more compliant with the ANSI C++ standards and it's free. The void main() definition despite not being defined in the standards has been usable in all the compilers I've used, but it's better to be safe than sorry.