Reputation:
So my go to language is C#, so I decided to learn C++. I made a hello world program with this code
#include <stdio.h> // include the standard input/output header file
void main(void) // our program starts here
{
printf("Hello World!"); // print "Hello World!" into the console
return; // return void to windows
}
But I then get this error when I compile (I am using Visual Studio 2015)
Error LNK1120 1 unresolved externals Render Engine c:\users\kamaldeep rai\documents\visual studio 2015\Projects\Render Engine\Debug\Render Engine.exe
Error LNK2019 unresolved external symbol _WinMain@16 referenced in function "int __cdecl invoke_main(void)" (?invoke_main@@YAHXZ) Render Engine c:\Users\kamaldeep rai\documents\visual studio 2015\Projects\Render Engine\Render Engine\MSVCRTD.lib(exe_winmain.obj)
Upvotes: 3
Views: 3660
Reputation: 18411
In addition to Paul's answer, here is how you can change the configuration so that linker would look for main
:
Also, your main
prototype is not compliant with C++, it should return int
Upvotes: 6
Reputation: 35440
This error:
Error LNK2019 unresolved external symbol _WinMain@16
is caused by not choosing the correct project type when building your application. Since you're using Visual Studio, you want to have a Win32 Console Application
project.
Instead, you chose a project that has WinMain
as the entry point instead of the traditional main
entry point.
Upvotes: 3