Dll verwenden schlägt fehl



  • Hallo
    ich versuche gerade in meinem Program eine dll zu verwenden aber das funktioniert nicht! ich bekomme immer die Fehler:

    1>xDll.obj : error LNK2001: Nicht aufgelöstes externes Symbol ""__declspec(dllimport) public: __thiscall CWin32DLL::CWin32DLL(void)" (__imp_??0CWin32DLL@@QAE@XZ)".
    1>xDll.obj : error LNK2001: Nicht aufgelöstes externes Symbol ""__declspec(dllimport) public: int __thiscall CWin32DLL::add(int,int)" (__imp_?add@CWin32DLL@@QAEHHH@Z)".
    1>xDll.obj : error LNK2001: Nicht aufgelöstes externes Symbol ""__declspec(dllimport) public: int __thiscall CWin32DLL::sub(int,int)" (__imp_?sub@CWin32DLL@@QAEHHH@Z)".
    1>xDll.obj : error LNK2001: Nicht aufgelöstes externes Symbol ""__declspec(dllimport) public: int __thiscall CWin32DLL::mul(int,int)" (__imp_?mul@CWin32DLL@@QAEHHH@Z)".
    

    Meine Headerdatei sieh so aus:

    #ifdef WIN32DLL_EXPORTS
    #define WIN32DLL_API __declspec(dllexport)
    #else
    #define WIN32DLL_API __declspec(dllimport)
    #endif
    
    class WIN32DLL_API CWin32DLL {
    public:
    	CWin32DLL(void);
    	// TODO: add your methods here.
    	int add(int a,int b);
    	int sub(int a,int b);
    	int mul(int a,int b);
    };
    
    extern WIN32DLL_API int nWin32DLL;
    
    WIN32DLL_API int fnWin32DLL(void);
    

    Was läuft da bitte schief? Die dll wird problemlos übersetzt!
    Danke



  • dll schrieb:

    ...

    Das Importieren und Exportieren von Klassen ist SEHR problematisch (Da es keine Binärkompatibilität bei Klassen unter C++ gibt). Davon abgesehen kennt der C++ Standard keine DLL, dies ist ein Plattformabhängiges Feature, gehört also auch in andere Unterforen.

    Grundsätzlich: C Schnittstellen in einer Bibliothek (dll, lib, so...) sind unproblematisch, C++ Schnittstellen sind wenn Compilerabhängig (und in der Regel sogar abhängig von der konkreten Compilerversion).



  • Dieser Thread wurde von Moderator/in evilissimo aus dem Forum C++ in das Forum WinAPI verschoben.

    Im Zweifelsfall bitte auch folgende Hinweise beachten:
    C/C++ Forum :: FAQ - Sonstiges :: Wohin mit meiner Frage?

    Dieses Posting wurde automatisch erzeugt.


Anmelden zum Antworten