<?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[Reine C++ Projekt erstellen und anwenden.]]></title><description><![CDATA[<p>Hallo zusammen,</p>
<p>ich habe einen Test Projekt als C++_DLL mit VS_2008 erstellt.<br />
Es sieht wie folgende aus:<br />
Person.h</p>
<pre><code>#pragma once

//class Person
//{
//public:
//	Person(void);
//	~Person(void);
//};

#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;windows.h&gt;

#ifdef __DLL__
# define DLLIMPORT __declspec(dllexport)
#else
# define DLLIMPORT __declspec(dllimport)
#endif

DLLIMPORT class Person
{
    std::string _sName;
    std::string _sVorname;
    std::string _sGeschlecht;
    int _iAlter;

public:
    DLLIMPORT Person();
    DLLIMPORT Person(std::string sName, std::string sVorname, std::string sGeschlecht, int iAlter);
    DLLIMPORT ~Person();

    DLLIMPORT const std::string GetName();
    DLLIMPORT const std::string GetVorname();
    DLLIMPORT const std::string GetGeschlecht();
    DLLIMPORT const int GetAlter();

    DLLIMPORT void SetName(const std::string sName);
    DLLIMPORT void SetVorname(const std::string sVorname);
    DLLIMPORT void SetGeschlecht(const std::string sGeschlecht);
    DLLIMPORT void SetAlter(const int iAlter);

    DLLIMPORT std::string SagHallo();
};
</code></pre>
<p>Person.cpp</p>
<pre><code>#include &quot;StdAfx.h&quot;
#include &quot;Person.h&quot;

//Person::Person(void)
//{
//}
//
//Person::~Person(void)
//{
//}
#define __dll__

#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;windows.h&gt;

DLLIMPORT Person::Person()
{
    _sName = &quot;&quot;;
    _sVorname = &quot;&quot;;
    _sGeschlecht = &quot;&quot;;
    _iAlter = 0;
}

DLLIMPORT Person::Person(std::string sName, std::string sVorname, std::string sGeschlecht, int iAlter)
{
    _sName = sName;
    _sVorname = sVorname;
    _sGeschlecht = sGeschlecht;
    _iAlter = iAlter;
}

DLLIMPORT Person::~Person()
{

}

DLLIMPORT const std::string Person::GetName()
{
    return _sName;
}

DLLIMPORT const std::string Person::GetVorname()
{
    return _sVorname;
}

DLLIMPORT const std::string Person::GetGeschlecht()
{
    return _sGeschlecht;
}

DLLIMPORT const int Person::GetAlter()
{
    return _iAlter;
}

DLLIMPORT void Person::SetName(const std::string sName)
{
    _sName = sName;
}

DLLIMPORT void Person::SetVorname(const std::string sVorname)
{
    _sVorname = sVorname;
}

DLLIMPORT void Person::SetGeschlecht(const std::string sGeschlecht)
{
    _sGeschlecht = sGeschlecht;
}

DLLIMPORT void Person::SetAlter(const int iAlter)
{
    _iAlter = iAlter;
}

DLLIMPORT std::string Person::SagHallo()
{
    char sAlter[5];
    sprintf(sAlter, &quot;%d&quot;, _iAlter);
    return &quot;Hallo, ich heisse &quot; + _sVorname + &quot; &quot; + _sName + &quot;, bin &quot; + _sGeschlecht + &quot; und &quot; + sAlter + &quot; Jahre alt.&quot;;
}
</code></pre>
<p>--&gt; beim Build bekomme ich folgende Fehlermeldungen:<br />
error C2491: 'Person::Person' : definition of dllimport function not allowed<br />
: error C2491: 'Person::Person' : definition of dllimport function not allowed<br />
: error C2491: 'Person::~Person' : definition of dllimport function not allowed<br />
: error C2491: 'Person::GetName' : definition of dllimport function not allowed<br />
: error C2491: 'Person::GetVorname' : definition of dllimport function not allowed<br />
: error C2491: 'Person::GetGeschlecht' : definition of dllimport function not allowed<br />
: error C2491: 'Person::GetAlter' : definition of dllimport function not allowed<br />
: error C2491: 'Person::SetName' : definition of dllimport function not allowed<br />
: error C2491: 'Person::SetVorname' : definition of dllimport function not allowed<br />
: error C2491: 'Person::SetGeschlecht' : definition of dllimport function not allowed<br />
: error C2491: 'Person::SetAlter' : definition of dllimport function not allowed<br />
: error C2491: 'Person::SagHallo' : definition of dllimport function not allowed</p>
<p>danke in voraus</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/326807/reine-c-projekt-erstellen-und-anwenden</link><generator>RSS for Node</generator><lastBuildDate>Mon, 25 May 2026 18:03:07 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/326807.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 08 Jul 2014 12:32:55 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Reine C++ Projekt erstellen und anwenden. on Tue, 08 Jul 2014 12:32:55 GMT]]></title><description><![CDATA[<p>Hallo zusammen,</p>
<p>ich habe einen Test Projekt als C++_DLL mit VS_2008 erstellt.<br />
Es sieht wie folgende aus:<br />
Person.h</p>
<pre><code>#pragma once

//class Person
//{
//public:
//	Person(void);
//	~Person(void);
//};

#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;windows.h&gt;

#ifdef __DLL__
# define DLLIMPORT __declspec(dllexport)
#else
# define DLLIMPORT __declspec(dllimport)
#endif

DLLIMPORT class Person
{
    std::string _sName;
    std::string _sVorname;
    std::string _sGeschlecht;
    int _iAlter;

public:
    DLLIMPORT Person();
    DLLIMPORT Person(std::string sName, std::string sVorname, std::string sGeschlecht, int iAlter);
    DLLIMPORT ~Person();

    DLLIMPORT const std::string GetName();
    DLLIMPORT const std::string GetVorname();
    DLLIMPORT const std::string GetGeschlecht();
    DLLIMPORT const int GetAlter();

    DLLIMPORT void SetName(const std::string sName);
    DLLIMPORT void SetVorname(const std::string sVorname);
    DLLIMPORT void SetGeschlecht(const std::string sGeschlecht);
    DLLIMPORT void SetAlter(const int iAlter);

    DLLIMPORT std::string SagHallo();
};
</code></pre>
<p>Person.cpp</p>
<pre><code>#include &quot;StdAfx.h&quot;
#include &quot;Person.h&quot;

//Person::Person(void)
//{
//}
//
//Person::~Person(void)
//{
//}
#define __dll__

#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;windows.h&gt;

DLLIMPORT Person::Person()
{
    _sName = &quot;&quot;;
    _sVorname = &quot;&quot;;
    _sGeschlecht = &quot;&quot;;
    _iAlter = 0;
}

DLLIMPORT Person::Person(std::string sName, std::string sVorname, std::string sGeschlecht, int iAlter)
{
    _sName = sName;
    _sVorname = sVorname;
    _sGeschlecht = sGeschlecht;
    _iAlter = iAlter;
}

DLLIMPORT Person::~Person()
{

}

DLLIMPORT const std::string Person::GetName()
{
    return _sName;
}

DLLIMPORT const std::string Person::GetVorname()
{
    return _sVorname;
}

DLLIMPORT const std::string Person::GetGeschlecht()
{
    return _sGeschlecht;
}

DLLIMPORT const int Person::GetAlter()
{
    return _iAlter;
}

DLLIMPORT void Person::SetName(const std::string sName)
{
    _sName = sName;
}

DLLIMPORT void Person::SetVorname(const std::string sVorname)
{
    _sVorname = sVorname;
}

DLLIMPORT void Person::SetGeschlecht(const std::string sGeschlecht)
{
    _sGeschlecht = sGeschlecht;
}

DLLIMPORT void Person::SetAlter(const int iAlter)
{
    _iAlter = iAlter;
}

DLLIMPORT std::string Person::SagHallo()
{
    char sAlter[5];
    sprintf(sAlter, &quot;%d&quot;, _iAlter);
    return &quot;Hallo, ich heisse &quot; + _sVorname + &quot; &quot; + _sName + &quot;, bin &quot; + _sGeschlecht + &quot; und &quot; + sAlter + &quot; Jahre alt.&quot;;
}
</code></pre>
<p>--&gt; beim Build bekomme ich folgende Fehlermeldungen:<br />
error C2491: 'Person::Person' : definition of dllimport function not allowed<br />
: error C2491: 'Person::Person' : definition of dllimport function not allowed<br />
: error C2491: 'Person::~Person' : definition of dllimport function not allowed<br />
: error C2491: 'Person::GetName' : definition of dllimport function not allowed<br />
: error C2491: 'Person::GetVorname' : definition of dllimport function not allowed<br />
: error C2491: 'Person::GetGeschlecht' : definition of dllimport function not allowed<br />
: error C2491: 'Person::GetAlter' : definition of dllimport function not allowed<br />
: error C2491: 'Person::SetName' : definition of dllimport function not allowed<br />
: error C2491: 'Person::SetVorname' : definition of dllimport function not allowed<br />
: error C2491: 'Person::SetGeschlecht' : definition of dllimport function not allowed<br />
: error C2491: 'Person::SetAlter' : definition of dllimport function not allowed<br />
: error C2491: 'Person::SagHallo' : definition of dllimport function not allowed</p>
<p>danke in voraus</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2407572</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2407572</guid><dc:creator><![CDATA[Niko_gast]]></dc:creator><pubDate>Tue, 08 Jul 2014 12:32:55 GMT</pubDate></item><item><title><![CDATA[Reply to Reine C++ Projekt erstellen und anwenden. on Tue, 08 Jul 2014 12:36:50 GMT]]></title><description><![CDATA[<p>Erstens sind Bezeichner mit doppelten Unterstrichen reserviert.<br />
Zweitens ist __dll__ etwas anderes als __DLL__.<br />
Drittens sollte die Define-Direktive vor der Include-Direktive stehen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2407573</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2407573</guid><dc:creator><![CDATA[MFK]]></dc:creator><pubDate>Tue, 08 Jul 2014 12:36:50 GMT</pubDate></item><item><title><![CDATA[Reply to Reine C++ Projekt erstellen und anwenden. on Tue, 08 Jul 2014 12:49:24 GMT]]></title><description><![CDATA[<p>Wenn die Klasse schon mit mit Im-/Export markiert ist, ist das für die einzelnen Funktion überflüssig.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2407574</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2407574</guid><dc:creator><![CDATA[manni66]]></dc:creator><pubDate>Tue, 08 Jul 2014 12:49:24 GMT</pubDate></item><item><title><![CDATA[Reply to Reine C++ Projekt erstellen und anwenden. on Tue, 08 Jul 2014 13:27:39 GMT]]></title><description><![CDATA[<p>manni66 schrieb:</p>
<blockquote>
<p>Wenn die Klasse schon mit mit Im-/Export markiert ist, ist das für die einzelnen Funktion überflüssig.</p>
</blockquote>
<p>Ist zwar lange her das ich mich damit beschäftigt habe, aber früher hatte jedes Beispiel (u.A. msdn) auch die Funktionen mit Im-/Export markiert. Ich würde daher deine Aussage zumindest mit Vorsicht genießen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2407584</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2407584</guid><dc:creator><![CDATA[asc]]></dc:creator><pubDate>Tue, 08 Jul 2014 13:27:39 GMT</pubDate></item><item><title><![CDATA[Reply to Reine C++ Projekt erstellen und anwenden. on Tue, 08 Jul 2014 13:30:01 GMT]]></title><description><![CDATA[<p><a href="http://msdn.microsoft.com/de-de/library/62688esh.aspx" rel="nofollow">http://msdn.microsoft.com/de-de/library/62688esh.aspx</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2407587</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2407587</guid><dc:creator><![CDATA[oenone]]></dc:creator><pubDate>Tue, 08 Jul 2014 13:30:01 GMT</pubDate></item><item><title><![CDATA[Reply to Reine C++ Projekt erstellen und anwenden. on Tue, 08 Jul 2014 13:45:38 GMT]]></title><description><![CDATA[<p>Hallo alle zusammen,</p>
<p>ich meine code so gepasst:<br />
Person.h</p>
<pre><code>#pragma once

#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;windows.h&gt;

#ifdef __DLL__
# define DLLIMPORT __declspec(dllexport)
#else
# define DLLIMPORT __declspec(dllimport)
#endif

DLLIMPORT class Person
{
    std::string _sName;
    std::string _sVorname;
    std::string _sGeschlecht;
    int _iAlter;

public:
     Person();
     Person(std::string sName, std::string sVorname, std::string sGeschlecht, int iAlter);
     ~Person();

     const std::string GetName();
     const std::string GetVorname();
     const std::string GetGeschlecht();
     const int GetAlter();

     void SetName(const std::string sName);
     void SetVorname(const std::string sVorname);
     void SetGeschlecht(const std::string sGeschlecht);
     void SetAlter(const int iAlter);

     std::string SagHallo();
};
</code></pre>
<p>Person.cpp</p>
<pre><code>#define __DLL__
#include &quot;StdAfx.h&quot;
#include &quot;Person.h&quot;
#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;windows.h&gt;

 Person::Person()
{
    _sName = &quot;&quot;;
    _sVorname = &quot;&quot;;
    _sGeschlecht = &quot;&quot;;
    _iAlter = 0;
}

 Person::Person(std::string sName, std::string sVorname, std::string sGeschlecht, int iAlter)
{
    _sName = sName;
    _sVorname = sVorname;
    _sGeschlecht = sGeschlecht;
    _iAlter = iAlter;
}

 Person::~Person()
{

}

 const std::string Person::GetName()
{
    return _sName;
}

 const std::string Person::GetVorname()
{
    return _sVorname;
}

 const std::string Person::GetGeschlecht()
{
    return _sGeschlecht;
}

 const int Person::GetAlter()
{
    return _iAlter;
}

 void Person::SetName(const std::string sName)
{
    _sName = sName;
}

 void Person::SetVorname(const std::string sVorname)
{
    _sVorname = sVorname;
}

 void Person::SetGeschlecht(const std::string sGeschlecht)
{
    _sGeschlecht = sGeschlecht;
}

 void Person::SetAlter(const int iAlter)
{
    _iAlter = iAlter;
}
 std::string Person::SagHallo()
{
    char sAlter[5];
    sprintf(sAlter, &quot;%d&quot;, _iAlter);
    return &quot;Hallo, ich heisse &quot; + _sVorname + &quot; &quot; + _sName + &quot;, bin &quot; + _sGeschlecht + &quot; und &quot; + sAlter + &quot; Jahre alt.&quot;;
}
</code></pre>
<p>Es werden keine Fehlermeldungen geworfen, aber es wird kein lib File erstellt.<br />
DLL wird schon erstellt, aber lib File nicht</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2407591</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2407591</guid><dc:creator><![CDATA[Niko_gast]]></dc:creator><pubDate>Tue, 08 Jul 2014 13:45:38 GMT</pubDate></item><item><title><![CDATA[Reply to Reine C++ Projekt erstellen und anwenden. on Tue, 08 Jul 2014 18:55:37 GMT]]></title><description><![CDATA[<p>Wenn du eine Lib möchtest, dann musst die dies dem VS2008 auch mitteilen, dieser kann für jede Projekt-Konfiguration entweder eine Dll oder eine lib erstellen.</p>
<p>Nachtrag: Projekt-Eigenschaften -&gt; Allgemein -&gt; Konfigurationstyp: steht wahrscheinlich auf &quot;Dynamische Bibliothek (.dll)&quot; und dies musst du auf &quot;Statische Bibliothek (.lib)&quot; umstellen. Dann solltest du aber die DLLIMPORT nicht mehr.</p>
<p>Mfg mdn</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2407657</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2407657</guid><dc:creator><![CDATA[Marc-O]]></dc:creator><pubDate>Tue, 08 Jul 2014 18:55:37 GMT</pubDate></item><item><title><![CDATA[Reply to Reine C++ Projekt erstellen und anwenden. on Wed, 09 Jul 2014 05:14:01 GMT]]></title><description><![CDATA[<p>Jetzt verstehe ich nicht<br />
Wenn ich noch einen Dummy projekt als DLL erstelle, muss ich eigentlich beide Datei (DLL file und lib file) bekomme.<br />
z.B dieses Projekt als DLL Projekt:</p>
<p>MathFuncsDLL.h</p>
<pre><code>#include &lt;iostream&gt;

#ifdef MATHFUNCSDLL_EXPORTS
#define MATHFUNCSDLL_API __declspec(dllexport) 
#else
#define MATHFUNCSDLL_API __declspec(dllimport) 
#endif

extern &quot;C&quot; MATHFUNCSDLL_API double Add(double a, double b); 

// Returns a - b
extern &quot;C&quot; MATHFUNCSDLL_API double Subtract(double a, double b); 

// Returns a * b
extern &quot;C&quot; MATHFUNCSDLL_API double Multiply(double a, double b); 

// Returns a / b
// Throws const std::invalid_argument&amp; if b is 0
extern &quot;C&quot; MATHFUNCSDLL_API double Divide(double a, double b);
</code></pre>
<p>MathFuncsDLL.cpp</p>
<pre><code>#include &quot;stdafx.h&quot;
#include &quot;MathFuncsDll.h&quot;
#include &lt;stdexcept&gt;

using namespace std;
    double Add(double a, double b)
    {
        return a + b;
    }

    double Subtract(double a, double b)
    {
        return a - b;
    }

    double Multiply(double a, double b)
    {
        return a * b;
    }

    double Divide(double a, double b)
    {
        if (b == 0)
        {
            throw invalid_argument(&quot;b cannot be zero!&quot;);
        }

        return a / b;
    }
</code></pre>
<p>--&gt; Okay der Code ist keine C++ sondern eher C</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2407686</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2407686</guid><dc:creator><![CDATA[Niko_gast]]></dc:creator><pubDate>Wed, 09 Jul 2014 05:14:01 GMT</pubDate></item><item><title><![CDATA[Reply to Reine C++ Projekt erstellen und anwenden. on Wed, 09 Jul 2014 05:58:45 GMT]]></title><description><![CDATA[<p>Niko_gast schrieb:</p>
<blockquote>
<p>Es werden keine Fehlermeldungen geworfen</p>
</blockquote>
<p>Und die Warnungen ignorierst du?</p>
<p>Erstens sind Bezeichner mit doppelten Unterstrichen reserviert.<br />
Zweitens muss es class DLLIMPORT Person heißen.<br />
Drittens sollte nichts vor der Include-Direktive für den vorcompilierten Header stehen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2407688</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2407688</guid><dc:creator><![CDATA[MFK]]></dc:creator><pubDate>Wed, 09 Jul 2014 05:58:45 GMT</pubDate></item><item><title><![CDATA[Reply to Reine C++ Projekt erstellen und anwenden. on Wed, 09 Jul 2014 05:59:05 GMT]]></title><description><![CDATA[<p>Nein musst du nicht, die dll brauchst du wenn du dynamisch linkst und die Lob wenn du statisch linkst.</p>
<p>Ich schau aber gerne. Nochmal nach sobald ich in der Firma meinen VS wieder vor mir hab.</p>
<p>MfG mdn</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2407689</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2407689</guid><dc:creator><![CDATA[Marc-O]]></dc:creator><pubDate>Wed, 09 Jul 2014 05:59:05 GMT</pubDate></item><item><title><![CDATA[Reply to Reine C++ Projekt erstellen und anwenden. on Wed, 09 Jul 2014 06:33:58 GMT]]></title><description><![CDATA[<p>MFK schrieb:</p>
<blockquote>
<p>Niko_gast schrieb:</p>
<blockquote>
<p>Es werden keine Fehlermeldungen geworfen</p>
</blockquote>
<p>Und die Warnungen ignorierst du?</p>
<p>Erstens sind Bezeichner mit doppelten Unterstrichen reserviert.<br />
Zweitens muss es class DLLIMPORT Person heißen.<br />
Drittens sollte nichts vor der Include-Direktive für den vorcompilierten Header stehen.</p>
</blockquote>
<p>Ich habe meine Code jetzt angepasst :<br />
Person.h</p>
<pre><code>#pragma once
#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;windows.h&gt;

#ifdef _DLL_
# define DLLIMPORT __declspec(dllexport)
#else
# define DLLIMPORT __declspec(dllimport)
#endif

 class DLLIMPORT Person
{
    std::string _sName;
    std::string _sVorname;
    std::string _sGeschlecht;
    int _iAlter;

public:
     Person();
     Person(std::string sName, std::string sVorname, std::string sGeschlecht, int iAlter);
     ~Person();

     const std::string GetName();
     const std::string GetVorname();
     const std::string GetGeschlecht();
     const int GetAlter();

     void SetName(const std::string sName);
     void SetVorname(const std::string sVorname);
     void SetGeschlecht(const std::string sGeschlecht);
     void SetAlter(const int iAlter);

     std::string SagHallo();
};
</code></pre>
<p>Person.cpp ist wie gelcih geblieben</p>
<p>--&gt; Es wird jetzt eine DLL file und lib file erstellt allerdings mit mehrere Warnungen wie z.B:<br />
warning C4273: 'Person::Person' : inconsistent dll linkage<br />
warning C4273: 'Person::Person' : inconsistent dll linkage<br />
warning C4273: 'Person::~Person' : inconsistent dll linkage<br />
warning C4273: 'Person::GetName' : inconsistent dll linkage</p>
<p>.. die Warnungen betreffen alle Funktionen der Class Person</p>
<p>Danke in voraus</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2407690</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2407690</guid><dc:creator><![CDATA[Niko_gast]]></dc:creator><pubDate>Wed, 09 Jul 2014 06:33:58 GMT</pubDate></item><item><title><![CDATA[Reply to Reine C++ Projekt erstellen und anwenden. on Wed, 09 Jul 2014 06:49:52 GMT]]></title><description><![CDATA[<p>Marc-O schrieb:</p>
<blockquote>
<p>Nein musst du nicht, die dll brauchst du wenn du dynamisch linkst und die Lob wenn du statisch linkst.</p>
</blockquote>
<p>Falsch. Unter windows mit dem VC++ compiler gibt es immer einer .lib datei.<br />
Denn der linker erwartet immer eine .lib datei</p>
<p>Die .lib enthält im falle eines DLL projektes informationen über all exportierten Symbole.<br />
Im Falle einer statischen lib enthält es den kompletten object code.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2407692</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2407692</guid><dc:creator><![CDATA[firefly]]></dc:creator><pubDate>Wed, 09 Jul 2014 06:49:52 GMT</pubDate></item><item><title><![CDATA[Reply to Reine C++ Projekt erstellen und anwenden. on Wed, 09 Jul 2014 06:55:36 GMT]]></title><description><![CDATA[<p>Erstens sind Bezeichner mit doppelten Unterstrichen reserviert.<br />
Zweitens sollte nichts vor der Include-Direktive für den vorcompilierten Header stehen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2407694</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2407694</guid><dc:creator><![CDATA[MFK]]></dc:creator><pubDate>Wed, 09 Jul 2014 06:55:36 GMT</pubDate></item><item><title><![CDATA[Reply to Reine C++ Projekt erstellen und anwenden. on Wed, 09 Jul 2014 07:04:43 GMT]]></title><description><![CDATA[<p>MFK schrieb:</p>
<blockquote>
<p>Erstens sind Bezeichner mit doppelten Unterstrichen reserviert.<br />
.</p>
</blockquote>
<p>Das ist schon erledigt oder (seh Person.h)?</p>
<p>MFK schrieb:</p>
<blockquote>
<p>Zweitens sollte nichts vor der Include-Direktive für den vorcompilierten Header stehen. .</p>
</blockquote>
<p>ehrlich gesagt weiss ich nicht genau was du meinst <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="😕"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2407695</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2407695</guid><dc:creator><![CDATA[Niko_gast]]></dc:creator><pubDate>Wed, 09 Jul 2014 07:04:43 GMT</pubDate></item><item><title><![CDATA[Reply to Reine C++ Projekt erstellen und anwenden. on Wed, 09 Jul 2014 07:15:46 GMT]]></title><description><![CDATA[<p>Niko_gast schrieb:</p>
<blockquote>
<p>Das ist schon erledigt oder (seh Person.h)?</p>
</blockquote>
<p>Stimmt, mein Fehler. Bezeichner, die mit einem Unterstrich und einem Großbuchstaben anfangen, sind aber auch reserviert <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>Niko_gast schrieb:</p>
<blockquote>
<p>ehrlich gesagt weiss ich nicht genau was du meinst <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="😕"
    /></p>
</blockquote>
<p>In Person.cpp steht die Include-Direktive für den vorcompilierten Header:</p>
<pre><code>#include &quot;StdAfx.h&quot;
</code></pre>
<p>Es sollte nichts vor dieser Zeile stehen. Deine Define-Direktive gehört also dahinter.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2407696</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2407696</guid><dc:creator><![CDATA[MFK]]></dc:creator><pubDate>Wed, 09 Jul 2014 07:15:46 GMT</pubDate></item><item><title><![CDATA[Reply to Reine C++ Projekt erstellen und anwenden. on Wed, 09 Jul 2014 07:26:58 GMT]]></title><description><![CDATA[<p>Es wurde erledigt aber die genannten warnungen sind immer noch da</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2407697</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2407697</guid><dc:creator><![CDATA[Niko_gast]]></dc:creator><pubDate>Wed, 09 Jul 2014 07:26:58 GMT</pubDate></item><item><title><![CDATA[Reply to Reine C++ Projekt erstellen und anwenden. on Wed, 09 Jul 2014 07:30:40 GMT]]></title><description><![CDATA[<p>Hallo wenn ich meine Person.h so umschreibe:</p>
<pre><code>#pragma once
#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;windows.h&gt;

//#ifdef _DLL_
//# define DLLIMPORT __declspec(dllexport)
//#else
//# define DLLIMPORT __declspec(dllimport)
//#endif

 class __declspec(dllexport) Person
{
    std::string _sName;
    std::string _sVorname;
    std::string _sGeschlecht;
    int _iAlter;

public:
     Person();
     Person(std::string sName, std::string sVorname, std::string sGeschlecht, int iAlter);
     ~Person();

     const std::string GetName();
     const std::string GetVorname();
     const std::string GetGeschlecht();
     const int GetAlter();

     void SetName(const std::string sName);
     void SetVorname(const std::string sVorname);
     void SetGeschlecht(const std::string sGeschlecht);
     void SetAlter(const int iAlter);

     std::string SagHallo();
};
</code></pre>
<p>Ich bekomme denn keine Warnung mehr</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2407698</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2407698</guid><dc:creator><![CDATA[Niko_gast]]></dc:creator><pubDate>Wed, 09 Jul 2014 07:30:40 GMT</pubDate></item><item><title><![CDATA[Reply to Reine C++ Projekt erstellen und anwenden. on Wed, 09 Jul 2014 07:41:03 GMT]]></title><description><![CDATA[<p>Niko_gast schrieb:</p>
<blockquote>
<p>Hallo wenn ich meine Person.h so umschreibe:</p>
<p>Ich bekomme denn keine Warnung mehr</p>
</blockquote>
<p>Du kannst diesen Header dann aber nicht mehr in Programmen verwenden, die die DLL benutzen sollen. Die brauchen an dieser Stelle dllimport.</p>
<p>Steht DLLIMPORT bei allen Methodendefinitionen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2407701</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2407701</guid><dc:creator><![CDATA[MFK]]></dc:creator><pubDate>Wed, 09 Jul 2014 07:41:03 GMT</pubDate></item><item><title><![CDATA[Reply to Reine C++ Projekt erstellen und anwenden. on Wed, 09 Jul 2014 08:02:31 GMT]]></title><description><![CDATA[<p>Hast du denn in deinem DLL-Projekt das Symbol &quot;_DLL_&quot; über die Projekt-Einstellungen auch definiert? (Findest du über C/C++ -&gt; Präprozessor, dort sollte es bei den Präprozessordefinitionen eingetragen sein.)</p>
<p>Bei deinen Projekten, die die DLL dann verwenden aber nicht.</p>
<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/1725">@firefly</a>: jup des mit der lib bei einer dll hab ich irgendwie verdrängt <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>Mfg mdn</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2407703</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2407703</guid><dc:creator><![CDATA[Marc-O]]></dc:creator><pubDate>Wed, 09 Jul 2014 08:02:31 GMT</pubDate></item><item><title><![CDATA[Reply to Reine C++ Projekt erstellen und anwenden. on Wed, 09 Jul 2014 08:04:17 GMT]]></title><description><![CDATA[<p>[quote=&quot;MFK&quot;]</p>
<p>Niko_gast schrieb:</p>
<blockquote>
<p>Steht DLLIMPORT bei allen Methodendefinitionen?</p>
</blockquote>
<p>Nein<br />
Person.cpp Teil ist gleich geblieben</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2407704</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2407704</guid><dc:creator><![CDATA[Niko_gast]]></dc:creator><pubDate>Wed, 09 Jul 2014 08:04:17 GMT</pubDate></item><item><title><![CDATA[Reply to Reine C++ Projekt erstellen und anwenden. on Wed, 09 Jul 2014 08:08:40 GMT]]></title><description><![CDATA[<p>Marc-O schrieb:</p>
<blockquote>
<p>Hast du denn in deinem DLL-Projekt das Symbol &quot;_DLL_&quot; über die Projekt-Einstellungen auch definiert? (Findest du über C/C++ -&gt; Präprozessor, dort sollte es bei den Präprozessordefinitionen eingetragen sein.)<br />
Mfg mdn</p>
</blockquote>
<p>es ist genau das<br />
danke</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2407705</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2407705</guid><dc:creator><![CDATA[Niko_gast]]></dc:creator><pubDate>Wed, 09 Jul 2014 08:08:40 GMT</pubDate></item><item><title><![CDATA[Reply to Reine C++ Projekt erstellen und anwenden. on Wed, 09 Jul 2014 08:21:29 GMT]]></title><description><![CDATA[<p>Hallo,<br />
ich muss noch mal fragen <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="😕"
    /></p>
<p>ich will jetzt den erzeugten DLL einfach testen<br />
Es gibt zwei Möglichkeiten: ich habe mich für die schwierige entschieden.<br />
ich bin so vorgegangen:</p>
<p>C++ projekt erstellen als Console Anwendung:<br />
main.cpp</p>
<pre><code>// CPP_DLL_Test.cpp : Defines the entry point for the console application.
//

#include &quot;stdafx.h&quot;
#include &lt;string&gt;
#include &lt;iostream&gt;
#include &lt;windows.h&gt;

typedef string (*GetName)();
typedef string (*GetVorname)();
typedef string (*GetGeschlecht)();
typedef int (*GetAlter)();

int main()
{
	GetName _GetName;
	GetVorname _GetVorname;
	GetGeschlecht _GetGeschlecht;
	GetAlter _GetAlter;
	HINSTANCE hInstLibrary = ::LoadLibrary(&quot;CPP_DLL.dll&quot;);

	if (hInstLibrary)
	{
		_GetName = (GetName)::GetProcAddress(hInstLibrary, &quot;GetName&quot;);
		_GetVorname = (GetVorname)::GetProcAddress(hInstLibrary, &quot;GetVorname&quot;);
		_GetGeschlecht = (GetGeschlecht)::GetProcAddress(hInstLibrary, &quot;GetGeschlecht&quot;);
		_GetAlter = (GetAlter)::GetProcAddress(hInstLibrary, &quot;GetAlter&quot;);

	if (_GetName)
	{
		std::cout &lt;&lt; &quot;DLL GetName Called &quot; &lt;&lt; std::endl;
	}

	FreeLibrary(hInstLibrary);
	}
	else
	{
		std::cout &lt;&lt; &quot;DLL Failed To Load!&quot; &lt;&lt; std::endl;
	}

	std::cin.get();

	return 0;
}
</code></pre>
<p>Ist meine Vorgehen richtig?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2407707</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2407707</guid><dc:creator><![CDATA[Niko_gast]]></dc:creator><pubDate>Wed, 09 Jul 2014 08:21:29 GMT</pubDate></item><item><title><![CDATA[Reply to Reine C++ Projekt erstellen und anwenden. on Wed, 09 Jul 2014 08:38:40 GMT]]></title><description><![CDATA[<p>Eher nicht.</p>
<p>Zum einen hast du den Header, über den du alle Definition der Klasse hast (Kannst also die Funktiondeklarationen weglassen), auserderm sind deine Funktionen, keine Freistehenden, sondern Member-Funktionen einer Klasse, daher glaub ich nicht, das du die so aufrufen könntest (Brauchst ja ein Objekt der Klasse).</p>
<p>Daher einfacheres Vorgehen:</p>
<ol>
<li>Erzeuge ein Konsolen-Projekt (hast du ja schon)</li>
<li>kopiere deine .h, .lib, .dll in die naehe deines neuen Projektes</li>
<li>Passe deine include- und lib-Pfad auf die vorher kopierten Dateien an</li>
<li>Dann füge noch einen Verweis auf die DLL hinzu</li>
<li>Includiere den Header in deiner &quot;CPP_DLL_Test.cpp&quot;</li>
<li>Benutze das Klasse nun so als hättest du sie in diesem Projekt geschrieben</li>
</ol>
<p>Mfg mdn</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2407712</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2407712</guid><dc:creator><![CDATA[Marc-O]]></dc:creator><pubDate>Wed, 09 Jul 2014 08:38:40 GMT</pubDate></item><item><title><![CDATA[Reply to Reine C++ Projekt erstellen und anwenden. on Wed, 09 Jul 2014 09:03:33 GMT]]></title><description><![CDATA[<p>Marc-O schrieb:</p>
<blockquote>
<p>Daher einfacheres Vorgehen:</p>
<ol>
<li>Erzeuge ein Konsolen-Projekt (hast du ja schon)</li>
<li>kopiere deine .h, .lib, .dll in die naehe deines neuen Projektes</li>
<li>Passe deine include- und lib-Pfad auf die vorher kopierten Dateien an</li>
<li>Dann füge noch einen Verweis auf die DLL hinzu</li>
<li>Includiere den Header in deiner &quot;CPP_DLL_Test.cpp&quot;</li>
<li>Benutze das Klasse nun so als hättest du sie in diesem Projekt geschrieben</li>
</ol>
<p>Mfg mdn</p>
</blockquote>
<p>Dieses vorgehen bringt mir nicht viel, da ich eigentlcih keine Lib File verwenden möchte.<br />
Ich möchte auch nicht den Headerfile verwende.</p>
<p>Ich möchte nur der DLL File benutzen.<br />
Ich habe einen Dummy Projekt(ausschliesslich C) erstellt, wo ich auch so vorgegangen bin:</p>
<pre><code>#include &quot;stdafx.h&quot;
    #include &lt;iostream&gt;
    #include &lt;windows.h&gt;

    typedef double (*AddFunc)(double,double);
	typedef double (*Subtract)(double,double);
	typedef double (*Multiply)(double,double);
    typedef double (*Divide)(double,double);

    int main()
	{
		AddFunc _AddFunc;
		Subtract _Subtract;
		Multiply _Multiply;
		Divide _Divide;
		HINSTANCE hInstLibrary = ::LoadLibrary(&quot;Dummy_DLL.dll&quot;);

		if (hInstLibrary)
		{
			_AddFunc = (AddFunc)::GetProcAddress(hInstLibrary, &quot;Add&quot;);
			_Subtract = (Subtract)::GetProcAddress(hInstLibrary, &quot;Subtract&quot;);
			_Multiply = (Multiply)::GetProcAddress(hInstLibrary, &quot;Multiply&quot;);
			_Divide = (Divide)::GetProcAddress(hInstLibrary, &quot;Divide&quot;);

			if (_AddFunc)
			{
				std::cout &lt;&lt; &quot;23 + 43 = &quot; &lt;&lt; _AddFunc(23, 43) &lt;&lt; std::endl;
			}
			if (_Subtract)
			{
				std::cout &lt;&lt; &quot;55 - 43 = &quot; &lt;&lt; _Subtract(55, 43) &lt;&lt; std::endl;
			}
			if (_Multiply)
			{
				std::cout &lt;&lt; &quot;60 * 10 = &quot; &lt;&lt; _Multiply(60, 10) &lt;&lt; std::endl;
			}
			if (_Divide)
			{
				std::cout &lt;&lt; &quot;300 / 50 = &quot; &lt;&lt; _Divide(300, 50) &lt;&lt; std::endl;
			}

			FreeLibrary(hInstLibrary);
			}
			else
			{
				std::cout &lt;&lt; &quot;DLL Failed To Load!&quot; &lt;&lt; std::endl;
			}

			std::cin.get();

			return 0;
    }
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2407718</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2407718</guid><dc:creator><![CDATA[Niko_gast]]></dc:creator><pubDate>Wed, 09 Jul 2014 09:03:33 GMT</pubDate></item><item><title><![CDATA[Reply to Reine C++ Projekt erstellen und anwenden. on Wed, 09 Jul 2014 09:10:16 GMT]]></title><description><![CDATA[<p>Niko_gast schrieb:</p>
<blockquote>
<p>Dieses vorgehen bringt mir nicht viel, da ich eigentlcih keine Lib File verwenden möchte.</p>
</blockquote>
<p>Warum war es dann ein Problem, dass keine Lib-Datei erstellt wurde?</p>
<p>Niko_gast schrieb:</p>
<blockquote>
<p>Ich möchte auch nicht den Headerfile verwende.</p>
</blockquote>
<p>Dann war das Gehampel mit der Umschaltung zwischen dllimport und dllexport unnötig.</p>
<p>Wenn du unbedingt über LoadLibrary/GetProcAddress gehen willst:<br />
Erstens passen deine Funktions-Typedefs nicht zu den exportierten Methoden.<br />
Zweitens passen die Namen der Symbole nicht. Schau dir mit dem Dependency Walker an, unter welchem Namen die DLL deine Methoden exportiert .</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2407721</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2407721</guid><dc:creator><![CDATA[MFK]]></dc:creator><pubDate>Wed, 09 Jul 2014 09:10:16 GMT</pubDate></item><item><title><![CDATA[Reply to Reine C++ Projekt erstellen und anwenden. on Wed, 09 Jul 2014 09:26:19 GMT]]></title><description><![CDATA[<p>Dann sollten die Funktionen mittels</p>
<pre><code class="language-cpp">extern &quot;C&quot;
</code></pre>
<p>deklariert werden (damit das C++ Name Mangeling abgestellt wird).</p>
<p>Und außerdem natürlich dann als freie (bzw. static Klassen-) Funktionen.</p>
<p>Aber welchen Sinn macht es, die DLL dynamisch per LoadLibrary zu laden (anstatt direkt dem Projekt hinzuzufügen)? Möchtest du ein Plugin-System verwenden?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2407726</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2407726</guid><dc:creator><![CDATA[Th69]]></dc:creator><pubDate>Wed, 09 Jul 2014 09:26:19 GMT</pubDate></item></channel></rss>