<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Linker Error bei Fenster-Erstellung]]></title><description><![CDATA[<p>Hej,<br />
ich fange gerade an, die WINAPI zu lernen und teste mich an einem Fenster. Hier der Code, falls benötigt:</p>
<pre><code class="language-cpp">#define STRICT

#include &lt;windows.h&gt;
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
const char szAppName[] = &quot;Ein eigenes Fenster&quot;;
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, 
                   PSTR szCmdLine, int iCmdShow)
{
   HWND       hWnd;
   MSG        msg;
   WNDCLASS   wc;
   wc.style         =  CS_HREDRAW | CS_VREDRAW;
   wc.lpfnWndProc   =  WndProc;
   wc.cbClsExtra    =  0;
   wc.cbWndExtra    =  0;
   wc.hInstance     =  hInstance;
   wc.hCursor       =  LoadCursor(NULL,IDC_ARROW);
   wc.hIcon         =  LoadIcon(NULL,IDI_APPLICATION);
   wc.hbrBackground =  (HBRUSH)GetStockObject(WHITE_BRUSH);
   wc.lpszClassName =  szAppName;
   wc.lpszMenuName  =  NULL;
   RegisterClass(&amp;wc);
   hWnd = CreateWindow(szAppName,
                       &quot;Titelleiste&quot;,
                       WS_OVERLAPPEDWINDOW,
                       CW_USEDEFAULT,          
                       CW_USEDEFAULT,          
                       CW_USEDEFAULT,          
                       CW_USEDEFAULT,         
                       NULL,
                       NULL,
                       hInstance,
                       NULL);
   ShowWindow(hWnd, iCmdShow);
   UpdateWindow(hWnd);
   while (GetMessage(&amp;msg, NULL, 0, 0))
   {
      TranslateMessage(&amp;msg);
      DispatchMessage(&amp;msg);
   }
   return msg.wParam;
}

LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
   switch (message)
   {
   case WM_DESTROY:
      {
         PostQuitMessage(0);
         return 0;
      }
   }
   return DefWindowProc(hWnd, message, wParam, lParam);
}
</code></pre>
<p>Wenn ich mit meinem Compiler (Bloodshed Dev-C++ 4.9.9.2) das kompilieren will, meldet er nur</p>
<pre><code>[Linker error] undefined reference to `GetStockObject@4' 
ld returned 1 exit status
</code></pre>
<p>Was kann ich da tun?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/230808/linker-error-bei-fenster-erstellung</link><generator>RSS for Node</generator><lastBuildDate>Thu, 09 Apr 2026 22:00:12 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/230808.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 02 Jan 2009 12:19:33 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Linker Error bei Fenster-Erstellung on Fri, 02 Jan 2009 12:20:10 GMT]]></title><description><![CDATA[<p>Hej,<br />
ich fange gerade an, die WINAPI zu lernen und teste mich an einem Fenster. Hier der Code, falls benötigt:</p>
<pre><code class="language-cpp">#define STRICT

#include &lt;windows.h&gt;
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
const char szAppName[] = &quot;Ein eigenes Fenster&quot;;
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, 
                   PSTR szCmdLine, int iCmdShow)
{
   HWND       hWnd;
   MSG        msg;
   WNDCLASS   wc;
   wc.style         =  CS_HREDRAW | CS_VREDRAW;
   wc.lpfnWndProc   =  WndProc;
   wc.cbClsExtra    =  0;
   wc.cbWndExtra    =  0;
   wc.hInstance     =  hInstance;
   wc.hCursor       =  LoadCursor(NULL,IDC_ARROW);
   wc.hIcon         =  LoadIcon(NULL,IDI_APPLICATION);
   wc.hbrBackground =  (HBRUSH)GetStockObject(WHITE_BRUSH);
   wc.lpszClassName =  szAppName;
   wc.lpszMenuName  =  NULL;
   RegisterClass(&amp;wc);
   hWnd = CreateWindow(szAppName,
                       &quot;Titelleiste&quot;,
                       WS_OVERLAPPEDWINDOW,
                       CW_USEDEFAULT,          
                       CW_USEDEFAULT,          
                       CW_USEDEFAULT,          
                       CW_USEDEFAULT,         
                       NULL,
                       NULL,
                       hInstance,
                       NULL);
   ShowWindow(hWnd, iCmdShow);
   UpdateWindow(hWnd);
   while (GetMessage(&amp;msg, NULL, 0, 0))
   {
      TranslateMessage(&amp;msg);
      DispatchMessage(&amp;msg);
   }
   return msg.wParam;
}

LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
   switch (message)
   {
   case WM_DESTROY:
      {
         PostQuitMessage(0);
         return 0;
      }
   }
   return DefWindowProc(hWnd, message, wParam, lParam);
}
</code></pre>
<p>Wenn ich mit meinem Compiler (Bloodshed Dev-C++ 4.9.9.2) das kompilieren will, meldet er nur</p>
<pre><code>[Linker error] undefined reference to `GetStockObject@4' 
ld returned 1 exit status
</code></pre>
<p>Was kann ich da tun?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1638308</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1638308</guid><dc:creator><![CDATA[Ad aCTa]]></dc:creator><pubDate>Fri, 02 Jan 2009 12:20:10 GMT</pubDate></item><item><title><![CDATA[Reply to Linker Error bei Fenster-Erstellung on Fri, 02 Jan 2009 12:20:48 GMT]]></title><description><![CDATA[<p>mit gdi32.lib linken</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1638309</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1638309</guid><dc:creator><![CDATA[RamboZamboTanztTango]]></dc:creator><pubDate>Fri, 02 Jan 2009 12:20:48 GMT</pubDate></item><item><title><![CDATA[Reply to Linker Error bei Fenster-Erstellung on Fri, 02 Jan 2009 12:32:34 GMT]]></title><description><![CDATA[<p>Tschuldige, wenn ich mich etwas dämlich anstelle, etwa so?</p>
<pre><code class="language-cpp">#include &quot;C:/Programme/Microsoft SDKs/Windows/v6.0A/Lib/Gdi32.Lib&quot;
</code></pre>
<p>Ich weiß nicht so genau, wie man &quot;linkt&quot;. Und diese Datei find ich auch nur in diesem Ordner.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1638317</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1638317</guid><dc:creator><![CDATA[Ad aCTa]]></dc:creator><pubDate>Fri, 02 Jan 2009 12:32:34 GMT</pubDate></item><item><title><![CDATA[Reply to Linker Error bei Fenster-Erstellung on Fri, 02 Jan 2009 12:41:05 GMT]]></title><description><![CDATA[<p>#pragma comment(lib, &quot;gdi32.lib&quot;) <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f44e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--thumbs_down"
      title=":-1:"
      alt="👎"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1638319</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1638319</guid><dc:creator><![CDATA[RamboZamboTanztTango]]></dc:creator><pubDate>Fri, 02 Jan 2009 12:41:05 GMT</pubDate></item><item><title><![CDATA[Reply to Linker Error bei Fenster-Erstellung on Fri, 02 Jan 2009 13:11:32 GMT]]></title><description><![CDATA[<p>Und das ergibt wieder</p>
<pre><code>[Linker error] undefined reference to `GetStockObject@4'
ld returned 1 exit status
</code></pre>
<p><img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
<p>Ich hab jetzt auch herrausgefunden, dass ich libgdi32.a und nicht .lib benötige, die ist auch im Lib-Verzeichnis von Dev-Cpp, aber leider bleibt der Fehler.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1638322</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1638322</guid><dc:creator><![CDATA[Ad aCTa]]></dc:creator><pubDate>Fri, 02 Jan 2009 13:11:32 GMT</pubDate></item><item><title><![CDATA[Reply to Linker Error bei Fenster-Erstellung on Fri, 02 Jan 2009 13:10:28 GMT]]></title><description><![CDATA[<p>Ad aCTa schrieb:</p>
<blockquote>
<p>Und das ergibt wieder</p>
<pre><code>[Linker error] undefined reference to `GetStockObject@4'
ld returned 1 exit status
</code></pre>
<p><img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
<p>Ich hab jetzt auch herrausgefunden, dass ich gdi32.a und nicht .lib benötige, die ist auch im Lib-Verzeichnis von Dev-Cpp, aber leider bleibt der Fehler.</p>
</blockquote>
<p>Projekt =&gt; Projekt Einstellungen =&gt; Linker Parameter (oder so)<br />
und da -lgdi32 oder gdi32.a eintragen</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1638336</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1638336</guid><dc:creator><![CDATA[evilissimo]]></dc:creator><pubDate>Fri, 02 Jan 2009 13:10:28 GMT</pubDate></item><item><title><![CDATA[Reply to Linker Error bei Fenster-Erstellung on Fri, 02 Jan 2009 13:16:45 GMT]]></title><description><![CDATA[<p>Ah, danke! Darauf wär' ich nie gekommen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1638337</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1638337</guid><dc:creator><![CDATA[Ad aCTa]]></dc:creator><pubDate>Fri, 02 Jan 2009 13:16:45 GMT</pubDate></item></channel></rss>