Failed to link Hello World!

Guys that are copied from a book (Windows Programming 5th Edition):

#include <windows.h>

int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
                    PSTR szCmdLine, int iCmdShow)
{
     MessageBox (NULL, TEXT ("Hello, Windows 98!"), TEXT ("HelloMsg"), 0) ;

     return 0 ;
}

Link to the topic in which this book is recommended. Unable to compile it with VS2010. What am I doing wrong?

Error   1   error LNK2001: unresolved external symbol _WinMainCRTStartup

Thank.

+3
source share
3 answers

It will depend on how you set up the project. In VS2010, if I create a new project via File-> New-> Project, Visual C ++, Empty Project, then add a new C ++ file and copy your code, it compiles and works just fine.

, . , "" → "" → "" "Windows (/SUBSYSTEM: WINDOWS)

API- Win32 , Windows. Windows , , , , API . 16- Windows 3.1 1992 32- Windows 7.

: , - > C/++ → , "", , ""

Properties- > Linker- > Input- > Ignore Default Libs No.

+5

Windows, :

  • "Linker/System/SubSystem" "Windows (/SUBSYSTEM: WINDOWS)"

, Windows GUI. , , ( , ).

+2

Make sure you really add the source file to the project. It worked for me.

0
source

Source: https://habr.com/ru/post/1743047/


All Articles