<?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 einbinden]]></title><description><![CDATA[<p>hallo,</p>
<p>ich ahbe folgendes Problem. Ich habe unter Matlab folgendes geschrieben:</p>
<p>m-file:</p>
<pre><code>function z=zahlenadd(x,y)
plot(sin(0:x:2*pi));
z=x+y;
</code></pre>
<p>daraus mit Hilfe des Matlab Compilers folgende Dateien erzeugt:</p>
<p>easy2.dll<br />
easy2.exports<br />
easy2.h<br />
easy2.lib<br />
easy2.cpp<br />
easy2_mcc_component_data.c</p>
<p>die lib und header datei habe ich hinzugefügt (auch lib gelinked) jedoch bekomme ich immer wieder unresolved externals...</p>
<p>ich benutze <a href="http://VS2003.net" rel="nofollow">VS2003.net</a><br />
folgendes habe ich bereits probiert:<br />
add reference --&gt; &quot;Error adding reference to the project&quot;<br />
regsvr32 &quot;easy2.dll&quot; (ich habe es auch mal in den system32 Ordner geschoben)</p>
<p>bin jetzt ein wenig ratlos...hat irgendjemand mal ein tip???</p>
<p>vielen dank schonmal</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/213566/dll-einbinden</link><generator>RSS for Node</generator><lastBuildDate>Wed, 14 Oct 2026 06:26:22 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/213566.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 19 May 2008 11:07:02 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to dll einbinden on Mon, 19 May 2008 11:07:02 GMT]]></title><description><![CDATA[<p>hallo,</p>
<p>ich ahbe folgendes Problem. Ich habe unter Matlab folgendes geschrieben:</p>
<p>m-file:</p>
<pre><code>function z=zahlenadd(x,y)
plot(sin(0:x:2*pi));
z=x+y;
</code></pre>
<p>daraus mit Hilfe des Matlab Compilers folgende Dateien erzeugt:</p>
<p>easy2.dll<br />
easy2.exports<br />
easy2.h<br />
easy2.lib<br />
easy2.cpp<br />
easy2_mcc_component_data.c</p>
<p>die lib und header datei habe ich hinzugefügt (auch lib gelinked) jedoch bekomme ich immer wieder unresolved externals...</p>
<p>ich benutze <a href="http://VS2003.net" rel="nofollow">VS2003.net</a><br />
folgendes habe ich bereits probiert:<br />
add reference --&gt; &quot;Error adding reference to the project&quot;<br />
regsvr32 &quot;easy2.dll&quot; (ich habe es auch mal in den system32 Ordner geschoben)</p>
<p>bin jetzt ein wenig ratlos...hat irgendjemand mal ein tip???</p>
<p>vielen dank schonmal</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1512153</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1512153</guid><dc:creator><![CDATA[shorie77]]></dc:creator><pubDate>Mon, 19 May 2008 11:07:02 GMT</pubDate></item><item><title><![CDATA[Reply to dll einbinden on Mon, 19 May 2008 11:22:08 GMT]]></title><description><![CDATA[<p>Wenn Du Linker- Errors hast, spielt die DLL noch keine Rolle.<br />
Nur die LIB Datei. (D.h. der Versuch, die DLL ins system32 Verzeichnis zu verschieben bringt nichts.)</p>
<p>Ich würde Dir empfehlen, mit dem Dependency Walker zu schauen, was exakt exportiert wird. Ev. heissen die Funktionen anders, sind noch C++ Mangled oder habe die falsche Calling Convention.</p>
<p><a href="http://www.dependencywalker.com/" rel="nofollow">http://www.dependencywalker.com/</a></p>
<p>Gruss Simon</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1512165</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1512165</guid><dc:creator><![CDATA[simon.gysi]]></dc:creator><pubDate>Mon, 19 May 2008 11:22:08 GMT</pubDate></item><item><title><![CDATA[Reply to dll einbinden on Mon, 19 May 2008 11:53:26 GMT]]></title><description><![CDATA[<p>danke echt ein sehr interessantes tool...</p>
<p>es hat mir gesagt das meine dll auf eine system dll zugreifen wollte, welche ich jetzt habe.</p>
<p>leider hilft mir das nicht wirklich, denn der fehler besteht weiterhin.</p>
<p>meine frage immernoch, binde ich die dll den überhaupt richtig ein? oder mache ich fehler beim einbinden der lib <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /> bin mir bei diesen sachen wirklich nicht so sicher.</p>
<p>danke</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1512182</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1512182</guid><dc:creator><![CDATA[shorie77]]></dc:creator><pubDate>Mon, 19 May 2008 11:53:26 GMT</pubDate></item><item><title><![CDATA[Reply to dll einbinden on Mon, 19 May 2008 12:14:36 GMT]]></title><description><![CDATA[<blockquote>
<p>meine frage immernoch, binde ich die dll den überhaupt richtig ein? oder mache ich fehler beim einbinden der lib <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /> bin mir bei diesen sachen wirklich nicht so sicher</p>
</blockquote>
<p>Die Idee ist korrekt.<br />
Kompilieren: Header müssen bekannt sein<br />
Linken: Lib muss bekannt sein (Dlls spielen hier noch keine Rolle!)<br />
Laufzeit: Dll muss bekannt sein</p>
<p>Offenbar gibts noch einen Fehler beim Linken:<br />
- Wird die Lib gefunden?<br />
- Gibts ev. Release / Debug Build der Lib?<br />
- Stimmen die Namen der exportierten Funktionen mit den importierten überein?<br />
- Stimmen die Calling Convertion (__cdecl etc.) überein?</p>
<p>Edit: Füge mal folgendes in deinen Code ein.</p>
<pre><code class="language-cpp">#pragma comment(lib, &quot;easy2.lib&quot;)
</code></pre>
<p>Grüsse Simon</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1512204</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1512204</guid><dc:creator><![CDATA[simon.gysi]]></dc:creator><pubDate>Mon, 19 May 2008 12:14:36 GMT</pubDate></item><item><title><![CDATA[Reply to dll einbinden on Mon, 19 May 2008 12:35:49 GMT]]></title><description><![CDATA[<p>das habe ich auch schon drin stehen...habe aber jetzt festgestellt, das der fehler irgendwo in der von Matlab erstellten datei liegt.</p>
<p>meine main ist jetzt leer, jedoch habe ich noch die easy2.cpp<br />
hier mal die code´s:<br />
main.cpp</p>
<pre><code>#include &lt;iostream&gt;
#include &quot;easy2.h&quot;

#pragma comment (lib,&quot;easy2.lib&quot;)

using namespace std;

int main(void)
{
	return 0;
}
</code></pre>
<p>und die easy2.cpp</p>
<pre><code>// MATLAB Compiler: 4.8 (R2008a)
// Date: Mon May 19 10:17:33 2008
// Arguments: &quot;-B&quot; &quot;macro_default&quot; &quot;-W&quot; &quot;cpplib:easy2&quot; &quot;-d&quot;
// &quot;D:\Untersuchungen\MATLAB to C++\Compiler easy\easy2\src&quot; &quot;-T&quot; &quot;link:lib&quot;
// &quot;-v&quot; &quot;D:\Untersuchungen\MATLAB to C++\zahlenadd.m&quot; 
//

#include &lt;stdio.h&gt;
#define EXPORTING_easy2 1
#include &quot;easy2.h&quot;
#ifdef __cplusplus
extern &quot;C&quot; {
#endif

extern mclComponentData __MCC_easy2_component_data;

#ifdef __cplusplus
}
#endif

static HMCRINSTANCE _mcr_inst = NULL;

#if defined( _MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__) || defined(__LCC__)
#ifdef __LCC__
#undef EXTERN_C
#endif
#include &lt;windows.h&gt;

static char path_to_dll[_MAX_PATH];

BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, void *pv)
{
    if (dwReason == DLL_PROCESS_ATTACH)
    {
        if (GetModuleFileName(hInstance, path_to_dll, _MAX_PATH) == 0)
            return FALSE;
    }
    else if (dwReason == DLL_PROCESS_DETACH)
    {
    }
    return TRUE;
}
#endif
#ifdef __cplusplus
extern &quot;C&quot; {
#endif

static int mclDefaultPrintHandler(const char *s)
{
  return mclWrite(1 /* stdout */, s, sizeof(char)*strlen(s));
}

#ifdef __cplusplus
} /* End extern &quot;C&quot; block */
#endif

#ifdef __cplusplus
extern &quot;C&quot; {
#endif

static int mclDefaultErrorHandler(const char *s)
{
  int written = 0;
  size_t len = 0;
  len = strlen(s);
  written = mclWrite(2 /* stderr */, s, sizeof(char)*len);
  if (len &gt; 0 &amp;&amp; s[ len-1 ] != '\n')
    written += mclWrite(2 /* stderr */, &quot;\n&quot;, sizeof(char));
  return written;
}

#ifdef __cplusplus
} /* End extern &quot;C&quot; block */
#endif

/* This symbol is defined in shared libraries. Define it here
 * (to nothing) in case this isn't a shared library. 
 */
#ifndef LIB_easy2_C_API 
#define LIB_easy2_C_API /* No special import/export declaration */
#endif

LIB_easy2_C_API 
bool MW_CALL_CONV easy2InitializeWithHandlers(
    mclOutputHandlerFcn error_handler,
    mclOutputHandlerFcn print_handler
)
{
  if (_mcr_inst != NULL)
    return true;
  if (!mclmcrInitialize())
    return false;
  if (!GetModuleFileName(GetModuleHandle(&quot;easy2&quot;), path_to_dll, _MAX_PATH))
    return false;
  if (!mclInitializeComponentInstanceWithEmbeddedCTF(&amp;_mcr_inst,
                                                     &amp;__MCC_easy2_component_data,
                                                     true, NoObjectType,
                                                     LibTarget, error_handler,
                                                     print_handler, 72956, path_to_dll))
    return false;
  return true;
}

LIB_easy2_C_API 
bool MW_CALL_CONV easy2Initialize(void)
{
  return easy2InitializeWithHandlers(mclDefaultErrorHandler,
                                     mclDefaultPrintHandler);
}

LIB_easy2_C_API 
void MW_CALL_CONV easy2Terminate(void)
{
  if (_mcr_inst != NULL)
    mclTerminateInstance(&amp;_mcr_inst);
}

LIB_easy2_C_API 
void MW_CALL_CONV easy2PrintStackTrace(void) 
{
  char** stackTrace;
  int stackDepth = mclGetStackTrace(_mcr_inst, &amp;stackTrace);
  int i;
  for(i=0; i&lt;stackDepth; i++)
  {
    mclWrite(2 /* stderr */, stackTrace[i], sizeof(char)*strlen(stackTrace[i]));
    mclWrite(2 /* stderr */, &quot;\n&quot;, sizeof(char)*strlen(&quot;\n&quot;));
  }
  mclFreeStackTrace(&amp;stackTrace, stackDepth);
}

LIB_easy2_C_API 
bool MW_CALL_CONV mlxZahlenadd(int nlhs, mxArray *plhs[],
                               int nrhs, mxArray *prhs[])
{
  return mclFeval(_mcr_inst, &quot;zahlenadd&quot;, nlhs, plhs, nrhs, prhs);
}

LIB_easy2_CPP_API 
void MW_CALL_CONV zahlenadd(int nargout, mwArray* z
                            , const mwArray* x, const mwArray* y)
{
  mclcppMlfFeval(_mcr_inst, &quot;zahlenadd&quot;, nargout, 1, 2, &amp;z, &amp;x, &amp;y);
}
</code></pre>
<p>da habe ich ca. 20 unresolved external errors...bsp:</p>
<p>easy2.obj : error LNK2019: unresolved external symbol _mclcppGetArrayBuffer_730_proxy referenced in function &quot;void __cdecl mclcppMlfFeval(void *,char const *,int,int,int,...)&quot; (?mclcppMlfFeval@@YAXPAXPBDHHHZZ)<br />
easy2.obj : error LNK2019: unresolved external symbol _mclcppGetLastError_proxy referenced in function &quot;public: static void __cdecl mwException::raise_error(void)&quot; (?raise_error@mwException@@SAXXZ)<br />
easy2.obj : error LNK2019: unresolved external symbol _mclcppCreateError_proxy referenced in function &quot;public: __thiscall mwException::mwException(void)&quot; (??0mwException@@QAE@XZ)</p>
<p>is mir wirklich nicht kalr woran das liegt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1512220</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1512220</guid><dc:creator><![CDATA[shorie77]]></dc:creator><pubDate>Mon, 19 May 2008 12:35:49 GMT</pubDate></item><item><title><![CDATA[Reply to dll einbinden on Mon, 19 May 2008 13:13:51 GMT]]></title><description><![CDATA[<p>Suche mal nach den Symbolen , die er nicht findet.<br />
Irgendwo müssen diese referenziert sein.<br />
Exportiert werden sie jedenfalls nicht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1512271</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1512271</guid><dc:creator><![CDATA[simon.gysi]]></dc:creator><pubDate>Mon, 19 May 2008 13:13:51 GMT</pubDate></item></channel></rss>