<?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[Standard DLL mit MFC erstellen und nutzen]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich versuche mit &quot;visual studio&quot; eine standard DLL zu erzeugen, die MFC (statisch verlinkt) benutzt.</p>
<p>RegisterServer.cpp:</p>
<pre><code>#include &quot;stdafx.h&quot;
#include &quot;RegisterServer.h&quot;

#ifdef _DEBUG
#define new DEBUG_NEW
#endif

		extern &quot;C&quot; char* PASCAL EXPORT RegisterServer(char* url)
		{
			AFX_MANAGE_STATE(AfxGetStaticModuleState());

			return &quot;hello&quot;;
		}

BEGIN_MESSAGE_MAP(CRegisterServerApp, CWinApp)
END_MESSAGE_MAP()

CRegisterServerApp::CRegisterServerApp()
{
}

CRegisterServerApp theApp;

BOOL CRegisterServerApp::InitInstance()
{
	CWinApp::InitInstance();

	return TRUE;
}
</code></pre>
<p>RegisterServer.def:</p>
<pre><code>; RegisterServer.def : Declares the module parameters for the DLL.

LIBRARY      &quot;RegisterServer&quot;

EXPORTS
    ; Explicit exports can go here
    RegisterServer
</code></pre>
<p>Jetzt moechte ich die Funktion in der DLL in einem normalen (nicht-mfc) visual c++ projekt nutzen:</p>
<p>UseDLL.cpp</p>
<pre><code>#include &quot;stdafx.h&quot;
#include&lt;iostream&gt;
using namespace std;

extern &quot;C&quot; __declspec(dllimport)char* RegisterServer (char* url);

int _tmain(int argc, _TCHAR* argv[])
{

	char* result = RegisterServer(&quot;blaa&quot;);

	cin.get();

	return 0;
}
</code></pre>
<p>Dazu habe ich alle DLL-Datein (und die LIB) in das Verzeichnis kopiert und zu der LIB verlinkt.</p>
<p>Ich erhalte aber folgende Fehlermeldungen:</p>
<blockquote>
<p>Error 1 error LNK2019: unresolved external symbol __imp__RegisterServer referenced in function _wmain UseDLL.obj<br />
Error 2 fatal error LNK1120: 1 unresolved externals G:\C Sharp\Dune2\UseDLL\Debug\UseDLL.exe 1</p>
</blockquote>
]]></description><link>https://www.c-plusplus.net/forum/topic/153932/standard-dll-mit-mfc-erstellen-und-nutzen</link><generator>RSS for Node</generator><lastBuildDate>Sat, 11 Apr 2026 15:21:25 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/153932.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 22 Jul 2006 07:45:38 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Standard DLL mit MFC erstellen und nutzen on Sat, 22 Jul 2006 07:45:38 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich versuche mit &quot;visual studio&quot; eine standard DLL zu erzeugen, die MFC (statisch verlinkt) benutzt.</p>
<p>RegisterServer.cpp:</p>
<pre><code>#include &quot;stdafx.h&quot;
#include &quot;RegisterServer.h&quot;

#ifdef _DEBUG
#define new DEBUG_NEW
#endif

		extern &quot;C&quot; char* PASCAL EXPORT RegisterServer(char* url)
		{
			AFX_MANAGE_STATE(AfxGetStaticModuleState());

			return &quot;hello&quot;;
		}

BEGIN_MESSAGE_MAP(CRegisterServerApp, CWinApp)
END_MESSAGE_MAP()

CRegisterServerApp::CRegisterServerApp()
{
}

CRegisterServerApp theApp;

BOOL CRegisterServerApp::InitInstance()
{
	CWinApp::InitInstance();

	return TRUE;
}
</code></pre>
<p>RegisterServer.def:</p>
<pre><code>; RegisterServer.def : Declares the module parameters for the DLL.

LIBRARY      &quot;RegisterServer&quot;

EXPORTS
    ; Explicit exports can go here
    RegisterServer
</code></pre>
<p>Jetzt moechte ich die Funktion in der DLL in einem normalen (nicht-mfc) visual c++ projekt nutzen:</p>
<p>UseDLL.cpp</p>
<pre><code>#include &quot;stdafx.h&quot;
#include&lt;iostream&gt;
using namespace std;

extern &quot;C&quot; __declspec(dllimport)char* RegisterServer (char* url);

int _tmain(int argc, _TCHAR* argv[])
{

	char* result = RegisterServer(&quot;blaa&quot;);

	cin.get();

	return 0;
}
</code></pre>
<p>Dazu habe ich alle DLL-Datein (und die LIB) in das Verzeichnis kopiert und zu der LIB verlinkt.</p>
<p>Ich erhalte aber folgende Fehlermeldungen:</p>
<blockquote>
<p>Error 1 error LNK2019: unresolved external symbol __imp__RegisterServer referenced in function _wmain UseDLL.obj<br />
Error 2 fatal error LNK1120: 1 unresolved externals G:\C Sharp\Dune2\UseDLL\Debug\UseDLL.exe 1</p>
</blockquote>
]]></description><link>https://www.c-plusplus.net/forum/post/1102107</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1102107</guid><dc:creator><![CDATA[UsulSK]]></dc:creator><pubDate>Sat, 22 Jul 2006 07:45:38 GMT</pubDate></item><item><title><![CDATA[Reply to Standard DLL mit MFC erstellen und nutzen on Wed, 22 Aug 2007 06:35:37 GMT]]></title><description><![CDATA[<p>Genau das Problem hab ich auch, und das PASCAL EXPORT in meiner dll kann(darf) ich nicht ändern.</p>
<p>Gibts da mittlerweile eine Lösung bzw wie importiert man dlls die mit PASCAL EXPORT arbeiten eigentlich richtig?!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1349482</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1349482</guid><dc:creator><![CDATA[pagan]]></dc:creator><pubDate>Wed, 22 Aug 2007 06:35:37 GMT</pubDate></item></channel></rss>