Page 3 of 4 FirstFirst 1234 LastLast
Results 21 to 30 of 32

Thread: Delphi libs can be used in C++ ?

  1. #21

    Delphi libs can be used in C++ ?

    NP, I struggled with these problems too so happy to share the stuff I've learned about it.

    1. You just need to export CreateInterface/DestroyInterface routines from your Delphi made dll, such as I outlined above.

    2. You need to dynamically load this DLL on the c++ side (use LoadLibrary) and bind to these two routines.

    3. Define the interface class on the C++ side and pass a pointer to this class to CreateInterface:
    Code:
    CMyClass *myclass;
    
    // create object instance
    CreateInterface(0, &myclass);
    ...
    
    // destroy object when your done
    DestroyInterface(&myclass);
    Note: You need to define the aObj as a pointer to a pointer (CreateInterface(int aIID, void **aObj); )because you need the modified pointer on return.
    Jarrod Davis
    Technical Director @ Piradyne Games

  2. #22

    Delphi libs can be used in C++ ?

    Quote Originally Posted by Pyrogine
    NP, I struggled with these problems too so happy to share the stuff I've learned about it.

    1. You just need to export CreateInterface/DestroyInterface routines from your Delphi made dll, such as I outlined above.

    2. You need to dynamically load this DLL on the c++ side (use LoadLibrary) and bind to these two routines.

    3. Define the interface class on the C++ side and pass a pointer to this class to CreateInterface:
    Code:
    CMyClass *myclass;
    
    // create object instance
    CreateInterface(0, &myclass);
    ...
    
    // destroy object when your done
    DestroyInterface(&myclass);
    Note: You need to define the aObj as a pointer to a pointer (CreateInterface(int aIID, void **aObj); )because you need the modified pointer on return.
    Here the code only compile with a single *, and works nice
    From brazil (:

    Pascal pownz!

  3. #23

    Delphi libs can be used in C++ ?

    Opps, yes, that is correct, only one * needed. You are passing by reference.

    Glad to hear it's working for you. Keep us posted on your progress.
    Jarrod Davis
    Technical Director @ Piradyne Games

  4. #24

    Delphi libs can be used in C++ ?

    Everything is working perfectly until now, i will post some results soon;
    From brazil (:

    Pascal pownz!

  5. #25

    Delphi libs can be used in C++ ?

    [quote="arthurprs"]chronozphere:~
    .lib are a file that C/C++ compilers use for static ]

    Only MSVC. GCC uses .a

  6. #26

    Delphi libs can be used in C++ ?



    someone know why c++ don't have inttostr? wtf!
    From brazil (:

    Pascal pownz!

  7. #27

    Delphi libs can be used in C++ ?

    Check sprintf.
    Jarrod Davis
    Technical Director @ Piradyne Games

  8. #28
    Co-Founder / PGD Elder WILL's Avatar
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    6,107
    Blog Entries
    25

    Delphi libs can be used in C++ ?

    Quote Originally Posted by arthurprs
    someone know why c++ don't have inttostr? wtf!
    C++ was invented by a telecom company... you do the math.
    Jason McMillen
    Pascal Game Development
    Co-Founder





  9. #29

    Delphi libs can be used in C++ ?

    Im getting real problems now,
    when compile the dll in FreePascal 2.2 the C++ program crashes...

    someone knows if freepascal have problems in abstract classes, sddcall or dll's :?:
    From brazil (:

    Pascal pownz!

  10. #30

    Delphi libs can be used in C++ ?

    The VMTs must match. I don't use FPC so I can't comment what the base object type is like, but make sure the VMT on the host side match what's on the DLL side. If you did not change the VMT on the C++ to match what it's like in FPC, then this can be a source of the problem. For example if you have more virtual methods in the C++ side than on the DLL side, when you call a c++ method it maybe calling the wrong method in the DLL side.

    So, make sure your virtual methods and the calling conventions all match. There maybe other issue related to FPC, but again, I don't use it so I'm unable to offer any suggestions on its usage, sorry.
    Jarrod Davis
    Technical Director @ Piradyne Games

Page 3 of 4 FirstFirst 1234 LastLast

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
  •