Results 1 to 4 of 4

Thread: Using Delphi DLL on C++

  1. #1

    Using Delphi DLL on C++

    I have a DLL writtten in Delphi that I want to use in a C++ program. It seems that in C++ you always need a .lib file (at least in Visual Studio), and I generated that from the .dll file.
    But still, it gives linker errors (it seems to be trying to import the functions as import_functionname instead of just functioname).
    Anyone here has experience of mixing C++ with Delphi?
    I could use LoadLibrary and load everything manually, but that's around 400 functions

  2. #2
    Quote Originally Posted by Relfos View Post
    I could use LoadLibrary and load everything manually, but that's around 400 functions
    You'll need to declare them anyway.

    There are a lot of time I didn't use DLL from C, but I remember it depends a lot from the compiler you're using. GCC, Borland C and Visual have different ways to define the "external" function. IIRC the simplest was GCC, just adding "extern" as a prefix:

    Code:
    extern pascal int myfoofunction (int param);
    Remember that you need the "pascal" word too (some compilers define a "PASCAL" macro too) and that names are lower-case.
    Last edited by Ñuño Martínez; 18-06-2012 at 12:13 PM.
    No signature provided yet.

  3. #3
    It seems that in C++ you always need a .lib
    This file is needed only for Visual C++ and Borland C++ as I remember. GCC can use dll without it(but maybe I'm wrong and there was somewhere *.a file around my dll, which I linked with project long time ago ). So the only way is using LoadLibrary and getting addresses of functions directly.

  4. #4
    I see, it seems that using LoadLibrary is the way to go then. I'll try to find a way to auto generate the bindings instead of having to write everything by hand
    www.pascalgameengine.com - Crossplatform 3D game engine

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •