<?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[Selbstgeschriebene DLL einbinden funzt nicht :(]]></title><description><![CDATA[<p>Hallo,<br />
Ich hab in Google folgendes Tutorial gefunden für das schreiben und einbinden von DLLs:<br />
<a href="http://www.developia.de/forum/viewtopic.php?t=40130" rel="nofollow">Tutorial</a><br />
Dann hab ich mit meinem DEV-C++ ein neues Projekt gemacht,ne DLL.<br />
Da hab ich dann folgendes reingeschrieben:</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;

/////ICH HAB lib.h GLEICH SO IN DEN SOURCE GESCHRIEBEN ;-)
#ifdef __cplusplus
#define EXPORT extern &quot;C&quot; __declspec (dllexport)
#else
#define EXPORT __declspec (dllexport)
#endif

EXPORT void CALLBACK Funktion(void); 
/////ende von lib.h 

int WINAPI DllMain (HINSTANCE hInstance, DWORD fdwReason, PVOID pvReserved)
{
return TRUE ;
}

EXPORT void CALLBACK Funktion(void)
{
MessageBox( NULL, &quot;Hallo Welt !&quot;, &quot;Info aus der DLL&quot;, MB_ICONINFORMATION );
}
</code></pre>
<p>die hat er auch Compiliert und ich habe lib.dll bekommen <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
<p>Danach hab ich ein neues Projekt angefangen,eine WIN32 Anwendung und folgendes &quot;reingeschrieben&quot; :</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;

/////ICH HAB lib.h GLEICH SO IN DEN SOURCE GESCHRIEBEN ;-)
#ifdef __cplusplus
#define EXPORT extern &quot;C&quot; __declspec (dllexport)
#else
#define EXPORT __declspec (dllexport)
#endif

EXPORT void CALLBACK Funktion(void); 
/////ende von lib.h

int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
{
Funktion();
return 0;
}
</code></pre>
<p>DLL liegt im gleichen Verzeichniss und er gibt mir trotzdem folgenden Fehler aus beim Versuch das Windwos Programm zu Compilieren:</p>
<blockquote>
<p>[Linker error] undefined reference to `Funktion@0'<br />
ld returned 1 exit status<br />
[...]\Makefile.win [Build Error] [projekt.exe] Error 1</p>
</blockquote>
<p>Weiß wer an was das liegen kann?<br />
Ich mach ja (hoffentlich) alles wie im Tutorial</p>
<p>Schon mal Danke,<br />
Mr.DLL <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/topic/137754/selbstgeschriebene-dll-einbinden-funzt-nicht</link><generator>RSS for Node</generator><lastBuildDate>Sun, 12 Jul 2026 23:48:02 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/137754.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 20 Feb 2006 15:10:03 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Selbstgeschriebene DLL einbinden funzt nicht :( on Mon, 20 Feb 2006 15:10:03 GMT]]></title><description><![CDATA[<p>Hallo,<br />
Ich hab in Google folgendes Tutorial gefunden für das schreiben und einbinden von DLLs:<br />
<a href="http://www.developia.de/forum/viewtopic.php?t=40130" rel="nofollow">Tutorial</a><br />
Dann hab ich mit meinem DEV-C++ ein neues Projekt gemacht,ne DLL.<br />
Da hab ich dann folgendes reingeschrieben:</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;

/////ICH HAB lib.h GLEICH SO IN DEN SOURCE GESCHRIEBEN ;-)
#ifdef __cplusplus
#define EXPORT extern &quot;C&quot; __declspec (dllexport)
#else
#define EXPORT __declspec (dllexport)
#endif

EXPORT void CALLBACK Funktion(void); 
/////ende von lib.h 

int WINAPI DllMain (HINSTANCE hInstance, DWORD fdwReason, PVOID pvReserved)
{
return TRUE ;
}

EXPORT void CALLBACK Funktion(void)
{
MessageBox( NULL, &quot;Hallo Welt !&quot;, &quot;Info aus der DLL&quot;, MB_ICONINFORMATION );
}
</code></pre>
<p>die hat er auch Compiliert und ich habe lib.dll bekommen <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
<p>Danach hab ich ein neues Projekt angefangen,eine WIN32 Anwendung und folgendes &quot;reingeschrieben&quot; :</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;

/////ICH HAB lib.h GLEICH SO IN DEN SOURCE GESCHRIEBEN ;-)
#ifdef __cplusplus
#define EXPORT extern &quot;C&quot; __declspec (dllexport)
#else
#define EXPORT __declspec (dllexport)
#endif

EXPORT void CALLBACK Funktion(void); 
/////ende von lib.h

int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
{
Funktion();
return 0;
}
</code></pre>
<p>DLL liegt im gleichen Verzeichniss und er gibt mir trotzdem folgenden Fehler aus beim Versuch das Windwos Programm zu Compilieren:</p>
<blockquote>
<p>[Linker error] undefined reference to `Funktion@0'<br />
ld returned 1 exit status<br />
[...]\Makefile.win [Build Error] [projekt.exe] Error 1</p>
</blockquote>
<p>Weiß wer an was das liegen kann?<br />
Ich mach ja (hoffentlich) alles wie im Tutorial</p>
<p>Schon mal Danke,<br />
Mr.DLL <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/998657</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/998657</guid><dc:creator><![CDATA[Mr. DLL]]></dc:creator><pubDate>Mon, 20 Feb 2006 15:10:03 GMT</pubDate></item><item><title><![CDATA[Reply to Selbstgeschriebene DLL einbinden funzt nicht :( on Mon, 20 Feb 2006 16:33:55 GMT]]></title><description><![CDATA[<p>Dein Tutorial ist entweder total daneben oder du hast es nicht richtig verstanden.<br />
sieh dir mal LoadLibrary() in der MSDN an. Deine DLL mag korrekt sein, aber die Laufzeiteinbindung ist totaler schwachsinn.</p>
<p>chris90</p>
]]></description><link>https://www.c-plusplus.net/forum/post/998744</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/998744</guid><dc:creator><![CDATA[chris90]]></dc:creator><pubDate>Mon, 20 Feb 2006 16:33:55 GMT</pubDate></item><item><title><![CDATA[Reply to Selbstgeschriebene DLL einbinden funzt nicht :( on Mon, 20 Feb 2006 17:13:46 GMT]]></title><description><![CDATA[<p>Das Tut ist total daneben <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /><br />
Ich hab jetzt folgenden Code von <a href="http://msdn.microsoft.com/library/deu/default.asp?url=/library/DEU/vccore/html/_core_getprocaddress.asp" rel="nofollow">hier</a> abgeändert:</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;

typedef UINT (CALLBACK* LPFNDLLFUNC1)(DWORD,UINT);

int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
{
HINSTANCE hDLL;               // Handle to DLL
LPFNDLLFUNC1 Funktion;    // Function pointer

hDLL = LoadLibrary(&quot;lib.dll&quot;);
if (hDLL != NULL)
{
 Funktion = (LPFNDLLFUNC1)GetProcAddress(hDLL,&quot;Funktion&quot;); 
   if (!Funktion)
   {
      FreeLibrary(hDLL);
      return 0;
   }
   else
   {
      Funktion();
   }
}

return 0;
}
</code></pre>
<p>aber er sagt immer</p>
<blockquote>
<p>In function `int WinMain(HINSTANCE__<em>, HINSTANCE__</em>, CHAR*, int)':<br />
too few arguments to function</p>
</blockquote>
<p>und makiert</p>
<pre><code class="language-cpp">Funktion();
</code></pre>
<p>aber Funktion() is doch void <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f62e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_open_mouth"
      title=":open_mouth:"
      alt="😮"
    /><br />
Wenn ich dann</p>
<pre><code class="language-cpp">Funktion(void);
</code></pre>
<p>schreibe kommt er immer mit</p>
<blockquote>
<p>In function `int WinMain(HINSTANCE__<em>, HINSTANCE__</em>, CHAR*, int)':<br />
expected primary-expression before &quot;void&quot;</p>
</blockquote>
<p>Weiß jemand was ich falsch mache?</p>
<p>Danke schon mal <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/998773</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/998773</guid><dc:creator><![CDATA[Mr. DLL]]></dc:creator><pubDate>Mon, 20 Feb 2006 17:13:46 GMT</pubDate></item><item><title><![CDATA[Reply to Selbstgeschriebene DLL einbinden funzt nicht :( on Mon, 20 Feb 2006 17:16:19 GMT]]></title><description><![CDATA[<p>Möglichkeiten gibt es derer viele.</p>
<p>Wenn man dem armen Drops schon LoadLibrary vor die Füsse wirft, dann doch auch gleich GetProcadress. Kann ja nicht so schwer sein.</p>
<p>Ausserdem kann man natürlich auch die die DLL linken. Soll heissen, du bindest in Deinem Projekt die Datei lib.lib mit ein. Wie das funktioniert, hängt ganz von der verwendeten GDI ab (Die Hilfe kann Dir sicher helfen).</p>
<p>Gruß André</p>
]]></description><link>https://www.c-plusplus.net/forum/post/998777</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/998777</guid><dc:creator><![CDATA[av_privat]]></dc:creator><pubDate>Mon, 20 Feb 2006 17:16:19 GMT</pubDate></item><item><title><![CDATA[Reply to Selbstgeschriebene DLL einbinden funzt nicht :( on Mon, 20 Feb 2006 17:20:56 GMT]]></title><description><![CDATA[<p>Du solltest die Definition Deines Funktionspointers prüfen.<br />
Der muss wohl so lauten:<br />
typedef void (CALLBACK* LPFNDLLFUNC1)(void);</p>
<p>Gruß André</p>
]]></description><link>https://www.c-plusplus.net/forum/post/998784</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/998784</guid><dc:creator><![CDATA[av_privat]]></dc:creator><pubDate>Mon, 20 Feb 2006 17:20:56 GMT</pubDate></item><item><title><![CDATA[Reply to Selbstgeschriebene DLL einbinden funzt nicht :( on Mon, 20 Feb 2006 17:39:46 GMT]]></title><description><![CDATA[<p>Wie bekomm ich denn die lib.lib?</p>
<p>Danke</p>
]]></description><link>https://www.c-plusplus.net/forum/post/998805</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/998805</guid><dc:creator><![CDATA[Mr. DLL]]></dc:creator><pubDate>Mon, 20 Feb 2006 17:39:46 GMT</pubDate></item><item><title><![CDATA[Reply to Selbstgeschriebene DLL einbinden funzt nicht :( on Mon, 20 Feb 2006 17:58:08 GMT]]></title><description><![CDATA[<p>wird afaik beim Erstellen der Dll miterstellt</p>
]]></description><link>https://www.c-plusplus.net/forum/post/998819</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/998819</guid><dc:creator><![CDATA[DarkFitzi]]></dc:creator><pubDate>Mon, 20 Feb 2006 17:58:08 GMT</pubDate></item><item><title><![CDATA[Reply to Selbstgeschriebene DLL einbinden funzt nicht :( on Mon, 20 Feb 2006 18:14:18 GMT]]></title><description><![CDATA[<p>Die findest Du im Debug oder Release Verzeichnis Deines Projektes.<br />
Im Zweifelsfall findet Du sie mit der Suchenfunktion des Win-Explorers. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
<p>Gruß André</p>
]]></description><link>https://www.c-plusplus.net/forum/post/998834</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/998834</guid><dc:creator><![CDATA[av_privat]]></dc:creator><pubDate>Mon, 20 Feb 2006 18:14:18 GMT</pubDate></item><item><title><![CDATA[Reply to Selbstgeschriebene DLL einbinden funzt nicht :( on Mon, 20 Feb 2006 18:56:43 GMT]]></title><description><![CDATA[<blockquote>
<p>; dlltool --base-file C:\DOKUME<sub>1\Root\LOKALE</sub>1\Temp/cca02660.base --output-exp lib.exp --dllname lib.dll --output-def liblib.def --no-export-all-symbols --add-stdcall-alias --exclude-symbol=DllMainCRTStartup@12 --def C:\DOKUME<sub>1\Root\LOKALE</sub>1\Temp/cca02660.def --output-lib liblib.a<br />
EXPORTS<br />
Funktion@0 @ 1<br />
Funktion = Funktion@0 @ 2</p>
</blockquote>
<p>DES?<br />
Des heißt aber liblib.def <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f62e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_open_mouth"
      title=":open_mouth:"
      alt="😮"
    /></p>
<p>Mr.DLL</p>
]]></description><link>https://www.c-plusplus.net/forum/post/998870</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/998870</guid><dc:creator><![CDATA[Mr. DLL]]></dc:creator><pubDate>Mon, 20 Feb 2006 18:56:43 GMT</pubDate></item><item><title><![CDATA[Reply to Selbstgeschriebene DLL einbinden funzt nicht :( on Mon, 20 Feb 2006 19:16:24 GMT]]></title><description><![CDATA[<p>So sorry wegen Doppelpost aber wenns liblib.def ist wie kann ich des mit einbinden?<br />
Schon mal Danke vorallem an av_privat <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
<p>Mr.DLL</p>
]]></description><link>https://www.c-plusplus.net/forum/post/998879</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/998879</guid><dc:creator><![CDATA[Mr. DLL]]></dc:creator><pubDate>Mon, 20 Feb 2006 19:16:24 GMT</pubDate></item><item><title><![CDATA[Reply to Selbstgeschriebene DLL einbinden funzt nicht :( on Tue, 21 Feb 2006 08:40:40 GMT]]></title><description><![CDATA[<p>hmm, die DEF-Datei ist aber nicht das richtige.<br />
Eher das Ende: --output-lib liblib.a<br />
Das scheint erfolgsversprechender zu sein. Allerdings muss das schon .lib am Ende haben. Ich habe leider keine Ahnung, wie das in der Entwicklungsumgebung funktioniert (zumindest scheint es kein Visual Studio zu sein). Da solltest Du mal das Handbuch oder die Hilfe konsultieren.</p>
<p>Andere Frage: Hat denn nun das GetProcadress funktioniert? Dann musst Du nicht mehr die Lib linken (eins von beidem reicht).</p>
<p>Gruß André</p>
]]></description><link>https://www.c-plusplus.net/forum/post/999120</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/999120</guid><dc:creator><![CDATA[av_privat]]></dc:creator><pubDate>Tue, 21 Feb 2006 08:40:40 GMT</pubDate></item><item><title><![CDATA[Reply to Selbstgeschriebene DLL einbinden funzt nicht :( on Tue, 21 Feb 2006 09:03:06 GMT]]></title><description><![CDATA[<p>aaalso:<br />
hier ein bisschen beispiel-code (stammt nicht von mir wie man sieht, läuft aber bei mir):</p>
<pre><code class="language-cpp">hinstLib = LoadLibrary(TEXT(&quot;Projekt1.dll&quot;)); 

                // If the handle is valid, try to get the function address.

                if (hinstLib != NULL) 
                { 
                    ProcAdd = (MYPROC) GetProcAddress(hinstLib, TEXT(&quot;myputs&quot;)); 

                    // If the function address is valid, call the function.

                    if (NULL != ProcAdd) 
                    {
                        fRunTimeLinkSuccess = TRUE;
                        (ProcAdd) (); 
                    }

                    // Free the DLL module.

                } 

                // If unable to call the DLL function, use an alternative.

                if (! fRunTimeLinkSuccess) 
                MessageBox(hwnd, &quot;ALtenatr method&quot;, &quot;sss&quot;, 0);            
                    fFreeResult = FreeLibrary(hinstLib);
</code></pre>
<p>EDIT: Hier kommt noch der &quot;header&quot;:</p>
<pre><code class="language-cpp">typedef int (*MYPROC)(); 
                HINSTANCE hinstLib; 
                MYPROC ProcAdd; 
                BOOL fFreeResult, fRunTimeLinkSuccess = FALSE;
</code></pre>
<p>greeetz<br />
chris90</p>
]]></description><link>https://www.c-plusplus.net/forum/post/999145</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/999145</guid><dc:creator><![CDATA[chris90]]></dc:creator><pubDate>Tue, 21 Feb 2006 09:03:06 GMT</pubDate></item><item><title><![CDATA[Reply to Selbstgeschriebene DLL einbinden funzt nicht :( on Tue, 21 Feb 2006 13:19:42 GMT]]></title><description><![CDATA[<p>Das Beispiel funktioniert mit Sicherheit für dieses Prblem.<br />
Allerdings möchte ich auf die Stolperfalle hinweisen. Auch hier stimmt die Definition des Funktionspointers nicht ganz. So wie ich den Code von Mr.DLL lese, hat seine CallBack den Rückkehrwert void. deshalb sollte die Definition so aussehen:</p>
<pre><code class="language-cpp">typedef void (*MYPROC)(void);
</code></pre>
<p>Gruß André</p>
]]></description><link>https://www.c-plusplus.net/forum/post/999364</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/999364</guid><dc:creator><![CDATA[av_privat]]></dc:creator><pubDate>Tue, 21 Feb 2006 13:19:42 GMT</pubDate></item><item><title><![CDATA[Reply to Selbstgeschriebene DLL einbinden funzt nicht :( on Tue, 21 Feb 2006 14:13:52 GMT]]></title><description><![CDATA[<p>So,<br />
das mit der DLL funzt jetzt <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /><br />
Danke nochmal</p>
<p>Mr. DLL</p>
]]></description><link>https://www.c-plusplus.net/forum/post/999430</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/999430</guid><dc:creator><![CDATA[Mr. DLL]]></dc:creator><pubDate>Tue, 21 Feb 2006 14:13:52 GMT</pubDate></item></channel></rss>