title: How do I set up the libraries correctly for Windows' GDI in C++?
body: <p>I want to make a C++ program that has live access to the pixels (colors and intensity e.g. bitmap) on the screen. One of the ways I think that should be possible is using Windows' GDI functions such as <a href="https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-createcompatibledc" rel="nofollow noreferrer">CreateCompatibleDC</a>. </p>
  
  <p>The problem is that when I try to run it, I get error message: 
  "
  C:\Users\Myname\AppData\Local\Temp\cce0hZ9w.o   Screencapture_example.cpp:(.text+0x30): undefined reference to `__imp_CreateCompatibleDC'
  "</p>
  
  <p>So it looks like the library containing the function is not present or not included. However I did include windows.h and wingdi.h, and according to the page in the link given above, the function is part of wingdi.h. </p>
  
  <p>It also says it requires library Gdi32.lib which I can't find anywhere on my computer. However there is a file called libgdi32.a, which sits in the folder C:\Programfiles\Dev-Cpp\MinGW64\x86_64-w64-mingw32\lib. I downloaded the gdi32.lib and added it to the same folder. The error message is unchanged when I recompile.</p>
  
  <p>That folder is included in the libraries section of the Dev-C++ editor, which uses the gcc compiler. My operating system is Windows 10.</p>
  
  <pre><code>#include&lt;windows.h&gt;
  #include&lt;wingdi.h&gt;
  int main(int argc,char *argv[]){
  
  HDC hdc = GetDC(NULL); // get the desktop device context
  HDC hDest = CreateCompatibleDC(hdc); // create a device context to use yourself
  
  //More to come here but I don't want to complicate it too much before
  //I get it to work this far.
  
  return 0;
  }
  </code></pre>