Borland Developer Studio 2006 C++ ungelöste Referenz bei DLL



  • Guten Tag.

    [Linker Fehler]Error: Ungelöste externe 'calculate(int, int)'
    Mein Beispiel:

    Eine simple MainGUI VCL

    C/C++ Code:
    __declspec(dllimport) int calculate( int a, int b);

    void __fastcall TMainForm::btn_calcClick(TObject *Sender)
    {
    int a = ted_a->Text.ToInt();
    int b = ted_b->Text.ToInt();
    ted_res->Text = IntToStr( calculate( a, b) );
    }
    C/C++ Code:
    __declspec(dllimport) int calculate( int a, int b);

    void __fastcall TMainForm::btn_calcClick(TObject *Sender)
    {
    int a = ted_a->Text.ToInt();
    int b = ted_b->Text.ToInt();
    ted_res->Text = IntToStr( calculate( a, b) );
    }
    C/C++ Code:
    __declspec(dllimport) int calculate( int a, int b);

    void __fastcall TMainForm::btn_calcClick(TObject *Sender)
    {
    int a = ted_a->Text.ToInt();
    int b = ted_b->Text.ToInt();
    ted_res->Text = IntToStr( calculate( a, b) );
    }

    sowie die kleine DLL

    C/C++ Code:
    extern "C" __declspec(dllexport) int calculate( int a, int b);
    #pragma argsused
    int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void* lpReserved)
    {
    return 1;
    }
    //---------------------------------------------------------------------------
    // NO __declspec(dllexport) int __stdcall calculate( int a, int b);

    int __stdcall calculate( int a, int b)
    {
    return a * b;
    }
    C/C++ Code:
    extern "C" __declspec(dllexport) int __stdcall calculate( int a, int b);
    #pragma argsused
    int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void* lpReserved)
    {
    return 1;
    }
    //---------------------------------------------------------------------------
    // NO __declspec(dllexport) int __stdcall calculate( int a, int b);

    int __stdcall calculate( int a, int b)
    {
    return a * b;
    }
    C/C++ Code:
    extern "C" __declspec(dllexport) int __stdcall calculate( int a, int b);
    #pragma argsused
    int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void* lpReserved)
    {
    return 1;
    }
    //---------------------------------------------------------------------------
    // NO __declspec(dllexport) int __stdcall calculate( int a, int b);

    int __stdcall calculate( int a, int b)
    {
    return a * b;
    }

    Ich habe ausser diesem einiges Versuch, irgendetwas fehlt mir an Wissen.
    Weiss jemand genau wie es geht?
    Ein Beispiel unter dem o.gen. Compiler was auch funktionier.
    Dann käme ich schon weiter.
    Dem Projekt hinzufügen die dll und oder die lib
    habe ich ebenfalls versucht.

    Recht herzlichen Dank für eine Antwort
    java ist eine schöne Insel



  • Lass doch bitte mal das __stdcall bei den Funktionsdefinitionen weg.
    Hier steht noch etwas zu dlls. Ist zwar BCB5 sollte aber auch im BDS funktionieren.
    http://bcb-tutorial.c-plusplus.net/DLL_Tutorial/index.html



  • Bitte die Faustregel beachten: ein Thema pro Thread, ein Thread pro Thema. Danke!


Anmelden zum Antworten