I want to learn to fix c/c++ linker problems in an IDE - agnostic way.
I’m starting the book Hands-On C++ Game Animation Programming
With the goal of Improving my C/C++ (I’m a novice) & Learning Open GL.
I’m using VS Code even though the book is using Visual Studio.
This is deliberate, because it’s not the syntax I need to learn,
It’s most often linker errors I hit when with C++ tutorials
LINKER PROBLEM
I have reached the point where I expect to render a blank window, and I am getting many linker errors
I am compiling with cl.exe
. Each error is one of LNK2019
or LNK2001
One example is
WinMain.obj : error LNK2019: unresolved external symbol __imp_ChoosePixelFormat referenced in function WinMain
WinMain.cpp has the following
// define constants to reduce the ammount of code included with windows.h
#define _CRT_SECURE_NO WARNINGS
#define WIN32_LEAN_AND_MEAN
#define WIN32_EXTRA_LEAN
#include <windows.h>
So I am including <windows.h>
but I guess an arbitrary subset of it?
VS Code finds the reference (F12) to ChoosePixelFormat
, but it is only a signature
WINGDIAPI int WINAPI ChoosePixelFormat( _In_ HDC hdc, _In_ CONST PIXELFORMATDESCRIPTOR *ppfd);
Inside
`C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\wingdi.h`
So I don’t know if the issue is
- the signature in
wingdi.h
is not sufficient for compiling - cl.exe does not ‘see’
wingdi.h
(maybe I need to edit a .vsode json file?) - some other C++ compiler/linker black magic I’m ignorant of
The situation above seems typical to all the linker errors I am getting.
Any help would be appreciated.
Hopefully someone has a linker error checklist they can share, when they hit linker errors…