title: Segmentation fault trying to execute a MinGW compiled C++ winapi test program
body: <p>I have trouble executing some winapi code. I don't know if the reason is because I missed something in the compilation process or if the test program is wrong; but when I execute the program the Bitmap defintion line is giving a <strong>segfault</strong>.</p>
  
  <p>here is the test program</p>
  
  <pre><code>#include &lt;windows.h&gt;
  #include &lt;gdiplus.h&gt;
  
  int WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
  {
    Gdiplus::PixelFormat* pf = new Gdiplus::PixelFormat();
    Gdiplus::Bitmap* bitmap = new Gdiplus::Bitmap(100, 100, *pf);
    return 0;
  }
  </code></pre>
  
  <p>and here is the compilation instruction  :</p>
  
  <pre><code>&gt; mingw32-g++ main.cpp -lgdiplus -o main.exe
  </code></pre>
  
  <p>When I execute, I have this throw :</p>
  
  <pre><code>Program received signal SIGSEGV, Segmentation fault.
  0x00403da3 in Gdiplus::Image::Image (this=0x0, image=0x0, status=Gdiplus::Ok) at c:/mingw/include/gdiplus/gdiplusheaders.h:142
  142                     nativeImage(image), lastStatus(status) {}
  </code></pre>
  
  <p><em>I did some winapi tutorial and created a window before so I think my MinGW installation has nothing wrong.</em></p>
  
  <p>What could be the problem ?</p>