Solved

How to call C++Builder DLL in Delphi?

Posted on 2000-04-06
5
526 Views
Last Modified: 2010-04-04
I've created a DLL that came from C++Builder code using the 'extern "C" __declspec(dllexport)' modifier to export the functions I want to be able to call.  It compiles okay and then when I try to run a test program in Delphi to call the functions, I get an "Entry Point Not Found" error.  More specifically it says "The procedure entry point <function name> could not be located in the dynamic link library <dll filename>".

I looked over my C++ code and I've seemed to have done everything right.  The only clue I have is from a Delphi book that tells me that I need to "translate the C++ import library to a Pascal equivalent inteface unit".  Am I on the right track?
0
Comment
Question by:uhoang
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 12

Accepted Solution

by:
rwilson032697 earned 50 total points
ID: 2691450
You can make a unit like this:

unit DLLinterface;

interface

Procedure Fred(Arg : Integer);

implementation

Procedure Fred(Arg : Integer); external 'MyDLL.DLL' name 'Fred';

end.

This will automatically load the DLL (if it can find it!) and allow you to call procedure fred defined in it.

It sounds like you might have the case of the function name wrong - be sure it matches!

Cheers,

Raymond.
0
 

Author Comment

by:uhoang
ID: 2691498
Ok, I did that and I still get the same result.  Is it possible that there's something wrong in the DLL?  After I build the DLL in C++Builder and place it in a folder in a correct path, do I need to do anything else like register it or anything?
0
 

Expert Comment

by:FMJMEE
ID: 2691505
See the web page
http://www.drbob42.com/delphi/headconv.htm
hope it helps
0
 
LVL 12

Expert Comment

by:rwilson032697
ID: 2691517
Can you post the declaration of the function in the DLL and in the import unit?

Cheers,

Raymond.
0
 
LVL 2

Expert Comment

by:Felixin
ID: 2692445
Hi,

Rwilson is OK.


You have to make sure that the protocol to call the DLL is correct.

Search i Delphi help for:

Calling conventions

There you will see that a DLL can have different calling methods, like (extracted)

The table below summarizes calling conventions.

Directive      Parameter order      Clean-up      Passes parameters in registers?
register      Left-to-right      Routine      Yes
pascal      Left-to-right      Routine      No
cdecl      Right-to-left      Caller      No
stdcall      Right-to-left      Routine      No
safecall      Right-to-left      Routine      No

Take the correct one a put it in the header of the function like this

function MyFunction : MyResult; cdecl; external 'MyDLL.DLL' name 'MyFunction';

Best regards
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question