Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Linker Error : error LNK2001

Status
Not open for further replies.

SCrystal

Programmer
May 7, 2002
14
0
0
US
Do you know any site where I can find information about how to use MS Visual C++.

I have done C programming but trying C++ programming.
Can anybody tell me what are these different types of projects. I have selected 'Win32 Application' and created a souce file with following code

#include<iostream.h>

int main()
{
cout << &quot;hello&quot;;
return 0;
}

but I am getting the following Link Error

Linking...
LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16
Debug/first.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

Any idea why this is occuring.
 
Do not choose Win32 Application, choose Console Application instead, then it will work.
 
return type for main function should always be void. so instead of int main(), do void main()
 
kjoy,

There are many who would argue that point: main() should always return int rather than void. In fact, the C++ book that I have says to do so.

I believe that the return value from main() can be picked up by calling programs to determine if an error occurred, particularly in batch files with the errorlevel variable.

It all comes down to preference I guess. If your main() returns int, you just have to make sure there's a &quot;return 0;&quot; line at the end.

Ian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top