I have problems compiling

Hey, I'm 3 episodes in and I have problems compiling
Here's the error message :
w:\handmade\code>cl win32_handmade.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 19.15.26726 for x64
Copyright (C) Microsoft Corporation. All rights reserved.

win32_handmade.cpp
Microsoft (R) Incremental Linker Version 14.15.26726.0
Copyright (C) Microsoft Corporation. All rights reserved.

/out:win32_handmade.exe
win32_handmade.obj
win32_handmade.obj : error LNK2019: unresolved external symbol __imp_CreateCompatibleDC referenced in function "void __cdecl Win32ResizeDIBSection(int,int)" (?Win32ResizeDIBSection@@YAXHH@Z)
win32_handmade.obj : error LNK2019: unresolved external symbol __imp_DeleteObject referenced in function "void __cdecl Win32ResizeDIBSection(int,int)" (?Win32ResizeDIBSection@@YAXHH@Z)
win32_handmade.obj : error LNK2019: unresolved external symbol __imp_StretchDIBits referenced in function "void __cdecl Win32UpdateWindow(struct HDC__ *,int,int,int,int)" (?Win32UpdateWindow@@YAXPEAUHDC__@@HHHH@Z)
win32_handmade.obj : error LNK2019: unresolved external symbol __imp_CreateDIBSection referenced in function "void __cdecl Win32ResizeDIBSection(int,int)" (?Win32ResizeDIBSection@@YAXHH@Z)
win32_handmade.obj : error LNK2019: unresolved external symbol __imp_GetMessageA referenced in function WinMain
win32_handmade.obj : error LNK2019: unresolved external symbol __imp_TranslateMessage referenced in function WinMain
win32_handmade.obj : error LNK2019: unresolved external symbol __imp_DispatchMessageA referenced in function WinMain
win32_handmade.obj : error LNK2019: unresolved external symbol __imp_DefWindowProcA referenced in function "__int64 __cdecl Win32MainWindowCallback(struct HWND__ *,unsigned int,unsigned __int64,__int64)" (?Win32MainWindowCallback@@YA_JPEAUHWND__@@I_K_J@Z)
win32_handmade.obj : error LNK2019: unresolved external symbol __imp_RegisterClassA referenced in function WinMain
win32_handmade.obj : error LNK2019: unresolved external symbol __imp_CreateWindowExA referenced in function WinMain
win32_handmade.obj : error LNK2019: unresolved external symbol __imp_BeginPaint referenced in function "__int64 __cdecl Win32MainWindowCallback(struct HWND__ *,unsigned int,unsigned __int64,__int64)" (?Win32MainWindowCallback@@YA_JPEAUHWND__@@I_K_J@Z)
win32_handmade.obj : error LNK2019: unresolved external symbol __imp_EndPaint referenced in function "__int64 __cdecl Win32MainWindowCallback(struct HWND__ *,unsigned int,unsigned __int64,__int64)" (?Win32MainWindowCallback@@YA_JPEAUHWND__@@I_K_J@Z)
win32_handmade.obj : error LNK2019: unresolved external symbol __imp_GetClientRect referenced in function "__int64 __cdecl Win32MainWindowCallback(struct HWND__ *,unsigned int,unsigned __int64,__int64)" (?Win32MainWindowCallback@@YA_JPEAUHWND__@@I_K_J@Z)
win32_handmade.exe : fatal error LNK1120: 13 unresolved externals

Edited by Mohammed Salim Boulaajine on Reason: added error message
You need to add gdi32.lib and user32.lib import libraries to your linker.

If you see "unresolved external symbol" error in linker, then you need to search where is this symbol. For example, lets take __imp_CreateCompatibleDC. Remove __imp_ prefix and search MSDN for CreateCompatibleDC function. You'll find this: https://docs.microsoft.com/en-us/...ngdi/nf-wingdi-createcompatibledc Scroll to the bottom and check what is written next to "Library"? gdi32.lib! And that is exactly what you need to add to your linker arguments.

You can see Casey explaining and doing this and the end of Episode 1 "Import a library": https://hero.handmade.network/episode/code/day001/#3720
Similar thing happened at end of Episode 2 "Drawing something with WM_PAINT": https://hero.handmade.network/episode/code/day002/#3375

And next time please copy&paste text instead of posting screenshot of text.

Edited by Mārtiņš Možeiko on
Thank you very much, sir!
my bad, I didn't pay enough attention.
I added the text message of the error.
Have a great day.