0

I am using the windows development kit for windows10, I prefer to use developer terminal instead of the Visual Studio IDE. When using the windows.h header, the following error appears in the console.

cl win.cpp
Compilador de optimización de C/C++ de Microsoft (R) versión 19.00.24245 para x86
(C) Microsoft Corporation. Todos los derechos reservados.

win.cpp
Microsoft (R) Incremental Linker Version 14.00.24245.0
Copyright (C) Microsoft Corporation.  All rights reserved.

/out:win.exe
win.obj
win.obj : error LNK2019: símbolo externo __imp__GetMessageW@16 sin resolver al que se hace referencia en la función _wWinMain@16
win.obj : error LNK2019: símbolo externo __imp__TranslateMessage@4 sin resolver al que se hace referencia en la función _wWinMain@16
win.obj : error LNK2019: símbolo externo __imp__DispatchMessageW@4 sin resolver al que se hace referencia en la función _wWinMain@16
win.obj : error LNK2019: símbolo externo __imp__DefWindowProcW@16 sin resolver al que se hace referencia en la función "long __stdcall WindowProc(struct HWND__ *,unsigned int,unsigned int,long)" (?WindowProc@@YGJPAUHWND__@@IIJ@Z)
win.obj : error LNK2019: símbolo externo __imp__PostQuitMessage@4 sin resolver al que se hace referencia en la función "long __stdcall WindowProc(struct HWND__ *,unsigned int,unsigned int,long)" (?WindowProc@@YGJPAUHWND__@@IIJ@Z)
win.obj : error LNK2019: símbolo externo __imp__RegisterClassW@4 sin resolver al que se hace referencia en la función _wWinMain@16
win.obj : error LNK2019: símbolo externo __imp__CreateWindowExW@48 sin resolver al que se hace referencia en la función _wWinMain@16
win.obj : error LNK2019: símbolo externo __imp__ShowWindow@8 sin resolver al que se hace referencia en la función _wWinMain@16
win.obj : error LNK2019: símbolo externo __imp__BeginPaint@8 sin resolver al que se hace referencia en la función "long __stdcall WindowProc(struct HWND__ *,unsigned int,unsigned int,long)" (?WindowProc@@YGJPAUHWND__@@IIJ@Z)
win.obj : error LNK2019: símbolo externo __imp__EndPaint@8 sin resolver al que se hace referencia en la función "long __stdcall WindowProc(struct HWND__ *,unsigned int,unsigned int,long)" (?WindowProc@@YGJPAUHWND__@@IIJ@Z)
win.obj : error LNK2019: símbolo externo __imp__FillRect@12 sin resolver al que se hace referencia en la función "long __stdcall WindowProc(struct HWND__ *,unsigned int,unsigned int,long)" (?WindowProc@@YGJPAUHWND__@@IIJ@Z)
win.exe : fatal error LNK1120: 11 externos sin resolver

I also did a search in my directories to see if the windows.h library was installed.

C:\Program Files (x86)\Windows Kits\10>dir *windows.h* /s
 El volumen de la unidad C no tiene etiqueta.
 El número de serie del volumen es: F838-52F2

 Directorio de C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\um

18/03/2019  01:31 p. m.             7,153 Windows.h
               1 archivos          7,153 bytes

 Directorio de C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\um

01/12/2020  11:04 p. m.             7,153 Windows.h
               1 archivos          7,153 bytes

 Directorio de C:\Program Files (x86)\Windows Kits\10\Include\10.0.20348.0\um

07/05/2021  04:23 p. m.             7,153 Windows.h
               1 archivos          7,153 bytes

 Directorio de C:\Program Files (x86)\Windows Kits\10\Include\10.0.22000.0\um

15/07/2022  04:07 p. m.             7,153 Windows.h
               1 archivos          7,153 bytes

 Directorio de C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um

19/10/2022  01:01 p. m.             7,511 Windows.h
               1 archivos          7,511 bytes

     Total de archivos en la lista:
               5 archivos         36,123 bytes
               0 dirs  166,071,943,168 bytes libres


I still don't know what the problem could be, how can I solve this?

  • 1
    The first thing you have to understand is that this is a **linker** error caused by a missing **library**. It has nothing to do with `windows.h` which is a **header file**. If the compiler was not able to find `windows.h` you would get an error message saying that. – john Apr 11 '23 at 05:21
  • 2
    You need to link the required Windows libraries for the functions you use in your code. To find these look up the functions, like [GetMessage](https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getmessage), then scroll to the bottom and see it needs `user32.lib`. Repeat for the rest. – Retired Ninja Apr 11 '23 at 05:24
  • 1
    It's hard to use the terminal to build windows software but if that is what you want to do then you have to list the **libraries** you want to link with when build your program. For example `GetMessageW` is in a library called `user32.lib` – john Apr 11 '23 at 05:24

0 Answers0