<?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[dll Erzeugung schlägt fehl]]></title><description><![CDATA[<p>Hallo zusammen,</p>
<p>habe mich an die dll Erzeugung herangewagt und mir ein einfaches Beispiel nach Anleitung ausgesucht. Ich bekomme aber jedesmal beim Kompilieren folgende Fehlermeldung:<br />
<strong>[Linker Error] Unresolved external 'TForm1::Addition(int, int)' referenced from D:\BORLAND\CBUILDER6\PROJECTS\UNIT1.OBJ</strong></p>
<p>Mein Code sieht dabei folgendermaßen aus:</p>
<p><strong>dllunit.cpp</strong></p>
<pre><code class="language-cpp">//---------------------------------------------------------------------------

#include &lt;vcl.h&gt;
#include &lt;windows.h&gt;
#pragma hdrstop
//---------------------------------------------------------------------------
//   Important note about DLL memory management when your DLL uses the
//   static version of the RunTime Library:
//
//   If your DLL exports any functions that pass String objects (or structs/
//   classes containing nested Strings) as parameter or function results,
//   you will need to add the library MEMMGR.LIB to both the DLL project and
//   any other projects that use the DLL.  You will also need to use MEMMGR.LIB
//   if any other projects which use the DLL will be performing new or delete
//   operations on any non-TObject-derived classes which are exported from the
//   DLL. Adding MEMMGR.LIB to your project will change the DLL and its calling
//   EXE's to use the BORLNDMM.DLL as their memory manager.  In these cases,
//   the file BORLNDMM.DLL should be deployed along with your DLL.
//
//   To avoid using BORLNDMM.DLL, pass string information using &quot;char *&quot; or
//   ShortString parameters.
//
//   If your DLL uses the dynamic version of the RTL, you do not need to
//   explicitly add MEMMGR.LIB as this will be done implicitly for you
//---------------------------------------------------------------------------

#pragma argsused
int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void* lpReserved)
{
        return 1;
}
//---------------------------------------------------------------------------

int __export Addition(int z1,int z2)
{
 return z1 + z2;
}
</code></pre>
<p><strong>Die Projekt Unit, in der die dll aufgerufen und verwendet wird</strong><br />
<strong>Unit1.h</strong></p>
<pre><code class="language-cpp">//---------------------------------------------------------------------------

#ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include &lt;Classes.hpp&gt;
#include &lt;Controls.hpp&gt;
#include &lt;StdCtrls.hpp&gt;
#include &lt;Forms.hpp&gt;
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published:	// IDE-managed Components
        TEdit *Edit1;
        TEdit *Edit2;
        TEdit *Edit3;
        TButton *Button1;
        void __fastcall Button1Click(TObject *Sender);
private:	// User declarations
public:		// User declarations
        __fastcall TForm1(TComponent* Owner);
        int __import Addition(int, int);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif
</code></pre>
<p><strong>Unit1.cpp</strong></p>
<pre><code class="language-cpp">//---------------------------------------------------------------------------

#include &lt;vcl.h&gt;
#pragma hdrstop

#include &quot;Unit1.h&quot;
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource &quot;*.dfm&quot;
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button1Click(TObject *Sender)
{
int a=StrToInt(Edit1-&gt;Text);
int b=StrToInt(Edit2-&gt;Text);
Edit3-&gt;Text=Addition(a,b);
}
//---------------------------------------------------------------------------
</code></pre>
<p>Habe die dll Unit kompiliert und erzeugt. Habe folgende Dateien bekommen:</p>
<p>addition.dll<br />
addition.lib<br />
...</p>
<p>Habe dann dem Projekt über Project-&gt;Add to Project die Datei addition.lib hinzugefügt und das ganze Kompiliert und wie oben genannt die Fehlermeldung bekommen.</p>
<p>Woran kann das liegen?</p>
<p>Danke<br />
Todd</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/187566/dll-erzeugung-schlägt-fehl</link><generator>RSS for Node</generator><lastBuildDate>Sun, 16 Aug 2026 16:55:50 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/187566.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 21 Jul 2007 07:52:59 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to dll Erzeugung schlägt fehl on Sat, 21 Jul 2007 07:52:59 GMT]]></title><description><![CDATA[<p>Hallo zusammen,</p>
<p>habe mich an die dll Erzeugung herangewagt und mir ein einfaches Beispiel nach Anleitung ausgesucht. Ich bekomme aber jedesmal beim Kompilieren folgende Fehlermeldung:<br />
<strong>[Linker Error] Unresolved external 'TForm1::Addition(int, int)' referenced from D:\BORLAND\CBUILDER6\PROJECTS\UNIT1.OBJ</strong></p>
<p>Mein Code sieht dabei folgendermaßen aus:</p>
<p><strong>dllunit.cpp</strong></p>
<pre><code class="language-cpp">//---------------------------------------------------------------------------

#include &lt;vcl.h&gt;
#include &lt;windows.h&gt;
#pragma hdrstop
//---------------------------------------------------------------------------
//   Important note about DLL memory management when your DLL uses the
//   static version of the RunTime Library:
//
//   If your DLL exports any functions that pass String objects (or structs/
//   classes containing nested Strings) as parameter or function results,
//   you will need to add the library MEMMGR.LIB to both the DLL project and
//   any other projects that use the DLL.  You will also need to use MEMMGR.LIB
//   if any other projects which use the DLL will be performing new or delete
//   operations on any non-TObject-derived classes which are exported from the
//   DLL. Adding MEMMGR.LIB to your project will change the DLL and its calling
//   EXE's to use the BORLNDMM.DLL as their memory manager.  In these cases,
//   the file BORLNDMM.DLL should be deployed along with your DLL.
//
//   To avoid using BORLNDMM.DLL, pass string information using &quot;char *&quot; or
//   ShortString parameters.
//
//   If your DLL uses the dynamic version of the RTL, you do not need to
//   explicitly add MEMMGR.LIB as this will be done implicitly for you
//---------------------------------------------------------------------------

#pragma argsused
int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void* lpReserved)
{
        return 1;
}
//---------------------------------------------------------------------------

int __export Addition(int z1,int z2)
{
 return z1 + z2;
}
</code></pre>
<p><strong>Die Projekt Unit, in der die dll aufgerufen und verwendet wird</strong><br />
<strong>Unit1.h</strong></p>
<pre><code class="language-cpp">//---------------------------------------------------------------------------

#ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include &lt;Classes.hpp&gt;
#include &lt;Controls.hpp&gt;
#include &lt;StdCtrls.hpp&gt;
#include &lt;Forms.hpp&gt;
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published:	// IDE-managed Components
        TEdit *Edit1;
        TEdit *Edit2;
        TEdit *Edit3;
        TButton *Button1;
        void __fastcall Button1Click(TObject *Sender);
private:	// User declarations
public:		// User declarations
        __fastcall TForm1(TComponent* Owner);
        int __import Addition(int, int);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif
</code></pre>
<p><strong>Unit1.cpp</strong></p>
<pre><code class="language-cpp">//---------------------------------------------------------------------------

#include &lt;vcl.h&gt;
#pragma hdrstop

#include &quot;Unit1.h&quot;
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource &quot;*.dfm&quot;
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button1Click(TObject *Sender)
{
int a=StrToInt(Edit1-&gt;Text);
int b=StrToInt(Edit2-&gt;Text);
Edit3-&gt;Text=Addition(a,b);
}
//---------------------------------------------------------------------------
</code></pre>
<p>Habe die dll Unit kompiliert und erzeugt. Habe folgende Dateien bekommen:</p>
<p>addition.dll<br />
addition.lib<br />
...</p>
<p>Habe dann dem Projekt über Project-&gt;Add to Project die Datei addition.lib hinzugefügt und das ganze Kompiliert und wie oben genannt die Fehlermeldung bekommen.</p>
<p>Woran kann das liegen?</p>
<p>Danke<br />
Todd</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1329608</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1329608</guid><dc:creator><![CDATA[Todd]]></dc:creator><pubDate>Sat, 21 Jul 2007 07:52:59 GMT</pubDate></item><item><title><![CDATA[Reply to dll Erzeugung schlägt fehl on Sat, 21 Jul 2007 10:04:06 GMT]]></title><description><![CDATA[<p>Habe jetzt eine andere Variante versucht und es klappt zumindest:</p>
<p><strong>dllUnit.cpp</strong></p>
<pre><code class="language-cpp">//---------------------------------------------------------------------------

#include &lt;vcl.h&gt;
#include &lt;windows.h&gt;
#pragma hdrstop
//---------------------------------------------------------------------------
//   Important note about DLL memory management when your DLL uses the
//   static version of the RunTime Library:
//   ....
//   If your DLL uses the dynamic version of the RTL, you do not need to
//   explicitly add MEMMGR.LIB as this will be done implicitly for you
//---------------------------------------------------------------------------
extern &quot;C&quot; __declspec(dllexport) int Min(int, int);
#pragma argsused
int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void* lpReserved)
{
        return 1;
}
//---------------------------------------------------------------------------

int Min(int z1,int z2)
{
 if (z1&gt;z2)
 return z2;
 else
 return z1;
}
</code></pre>
<p><strong>ProjectUnit.cpp</strong></p>
<pre><code class="language-cpp">//---------------------------------------------------------------------------

#include &lt;vcl.h&gt;
#pragma hdrstop

#include &quot;MainUnit.h&quot;
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource &quot;*.dfm&quot;
extern &quot;C&quot; __declspec(dllimport) int Min(int, int);

TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Edit1-&gt;Text=Min(7,2);
}
</code></pre>
<p>Die Header Datei wurde dabei unverändert gelassen...</p>
<p>Wie gesagt so funkioniert es, mich würde trotzdem interesseiren, warum die erste Variante nicht funktioniert.<br />
Vielleicht hat ja jemand von euch eine Idee...</p>
<p>Danke und Liebe Grüße<br />
Todd</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1329652</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1329652</guid><dc:creator><![CDATA[Todd]]></dc:creator><pubDate>Sat, 21 Jul 2007 10:04:06 GMT</pubDate></item><item><title><![CDATA[Reply to dll Erzeugung schlägt fehl on Sat, 21 Jul 2007 11:01:38 GMT]]></title><description><![CDATA[<p>Genau die gleiche Fehlermeldung habe ich bei meinem Programm, jetzt werd ich mal deine Variante versuchen ^^</p>
<p>Wäre allerdings wirklich interessant was genau diesen Fehler hervorruft <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>//edit</p>
<p>Bei mir ändert das nichts, ich bekomme immer noch diese Fehlermeldung von wegen &quot;Unresolved external ...&quot;.</p>
<p>Ich arbeite gerade mit dem Profibus (wenn das jemanden hilft) von Siemens - zwar schon etwas älter aber so lautet halt mein Auftrag.</p>
<p>Ich soll eine DLL erstellen um den Profibus anzusteuern und bestimmte Daten aus einem Datenfile zu verarbeiten. Die Funktionen für die Ansteuerung hab ich schon fertig, soll sie aber wie gesagt nun in eine DLL verpacken, damit sie nachher leichter verwendet werden kann.<br />
In meinen Funktionen verwende ich 5 von Siemens vorgegebene Funktionen (DP_start_cp, DP_open, DP_get_err_txt, DP_get_pointer und DP_set_mode). Jedoch bekomme ich beim erstellen meiner DLL immer die Fehlermeldung mit &quot;Unresolved external &lt;func&gt; referenced from &quot;C:\..\profibus.obj&quot; und das nur bei den 5 Funktionen von Siemens.<br />
Die Funktionen sind allerdings in der DP_BASE.dll vorhanden und auch in der DP_BASE.LIB, welche ich in mein Projekt eingebunden habe.<br />
Weiß da vielleicht irgendjemand Rat?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1329665</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1329665</guid><dc:creator><![CDATA[SeniiX]]></dc:creator><pubDate>Sat, 21 Jul 2007 11:01:38 GMT</pubDate></item><item><title><![CDATA[Reply to dll Erzeugung schlägt fehl on Sat, 21 Jul 2007 11:24:14 GMT]]></title><description><![CDATA[<p>Tritt der Fehler auch auf, wenn du jede einzelne Funktion exportierst, d.h. wenn dein dll.cpp folgendermaßen aufgebaut ist:</p>
<p><strong>dll.cpp</strong></p>
<pre><code class="language-cpp">//---------------------------------------------------------------------------
#include &lt;vcl.h&gt;
#include &lt;windows.h&gt;
#pragma hdrstop
//---------------------------------------------------------------------------
//   Important note about DLL memory management when your DLL uses the
//   static version of the RunTime Library:
//   ....
//   If your DLL uses the dynamic version of the RTL, you do not need to
//   explicitly add MEMMGR.LIB as this will be done implicitly for you
//---------------------------------------------------------------------------
extern &quot;C&quot; __declspec(dllexport) typ func1(...)
extern &quot;C&quot; __declspec(dllexport) typ func2(...)
//usw...
#pragma argsused
int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void* lpReserved)
{
        return 1;
}
//---------------------------------------------------------------------------

typ func1(...)
{...}

typ func2(...)
{...}

//usw...
</code></pre>
<p>Die Einbindung muss natürlich dann auch für jede Funktion extra geschehn:</p>
<p><strong>MainUnit.cpp</strong></p>
<pre><code class="language-cpp">//---------------------------------------------------------------------------

#include &lt;vcl.h&gt;
#pragma hdrstop

#include &quot;MainUnit.h&quot;
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource &quot;*.dfm&quot;
extern &quot;C&quot; __declspec(dllimport) typ func1(...);
extern &quot;C&quot; __declspec(dllimport) typ func2(...);
//usw...

TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
}
</code></pre>
<p>Vielleicht war es das ja schon.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1329685</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1329685</guid><dc:creator><![CDATA[Todd]]></dc:creator><pubDate>Sat, 21 Jul 2007 11:24:14 GMT</pubDate></item><item><title><![CDATA[Reply to dll Erzeugung schlägt fehl on Sat, 21 Jul 2007 13:24:24 GMT]]></title><description><![CDATA[<p>Nein, so funktioniert es auch nicht.</p>
<p>Inzwischen hab ich in den Borland C++ Builder FAQs etwas zu Thema DLLs einbinden gefunden. Damit funktioniert es jetzt auch.</p>
<p>Danke trotzdem für deine Hilfe <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>Falls du Interesse hast hier der Link: <a href="http://www.c-plusplus.net/forum/viewtopic-var-t-is-39265.html" rel="nofollow">http://www.c-plusplus.net/forum/viewtopic-var-t-is-39265.html</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1329756</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1329756</guid><dc:creator><![CDATA[SeniiX]]></dc:creator><pubDate>Sat, 21 Jul 2007 13:24:24 GMT</pubDate></item><item><title><![CDATA[Reply to dll Erzeugung schlägt fehl on Sat, 21 Jul 2007 16:34:37 GMT]]></title><description><![CDATA[<p>Jab, den Link hab ich mir schon durchgelesen. Finde ich nur etwas umständlich.<br />
Mache das jetzt nicht wie ich oben gepostet hab, statisch, sondern benutze die dynamische Einbindung der DLL's...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1329892</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1329892</guid><dc:creator><![CDATA[Todd]]></dc:creator><pubDate>Sat, 21 Jul 2007 16:34:37 GMT</pubDate></item><item><title><![CDATA[Reply to dll Erzeugung schlägt fehl on Sun, 22 Jul 2007 10:19:09 GMT]]></title><description><![CDATA[<p>Gibts dazu einen Link oder sowas? Wenn, dann poste ihn bitte <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/1330134</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1330134</guid><dc:creator><![CDATA[SeniiX]]></dc:creator><pubDate>Sun, 22 Jul 2007 10:19:09 GMT</pubDate></item><item><title><![CDATA[Reply to dll Erzeugung schlägt fehl on Sun, 22 Jul 2007 10:31:45 GMT]]></title><description><![CDATA[<p>Hallo</p>
<p>Alles wichtige zu DLLs im Builder wird hier in <a href="http://bcb-tutorial.c-plusplus.net/inhalt.html" rel="nofollow">unserem Tutorial</a> erklärt.</p>
<p>bis bald<br />
akari</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1330140</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1330140</guid><dc:creator><![CDATA[akari]]></dc:creator><pubDate>Sun, 22 Jul 2007 10:31:45 GMT</pubDate></item><item><title><![CDATA[Reply to dll Erzeugung schlägt fehl on Sun, 22 Jul 2007 10:36:27 GMT]]></title><description><![CDATA[<p>Herzlichen Dank akari!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1330143</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1330143</guid><dc:creator><![CDATA[SeniiX]]></dc:creator><pubDate>Sun, 22 Jul 2007 10:36:27 GMT</pubDate></item></channel></rss>