Solved

Can't use a C++ (v7.1) and MFC DLL in Delphi 6.....

Posted on 2004-09-28
7
219 Views
Last Modified: 2006-11-17
I'm using Delphi 6 (Pascal) to load a C++/MFC DLL. In Delphi, after I load the library, I can see the entry points in the library. One of the functions in the library is TrackData. The entry point should be TrackData but it looks like this instead:

?TrackData@@YAHPAD@Z

I have never had a problem using a library in Delphi before. This DLL was written by another person in a sister company and I think that they need to do something to better expose the functions within their library but I'm not a C++ programmer so I wouldn't know what to tell them. It may not be a problem with their library or my loading of it. It may just be an incompatibility problem.

What I need is some kind of direction as to what they are not doing that needs to be done. Code examples or anything would be helpful. I know this isn't much to go on but ask me anything and I'll get back to you as soon as I can. If you have a question for the C++ programmer, give it to me and I'll relay it to them.

Extra Info: All parameters within the DLL functions are compatible with Delphi.

Thanks for any help given.


0
Comment
Question by:blueyellowgreen
[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
  • 4
  • 3
7 Comments
 
LVL 14

Accepted Solution

by:
wayside earned 500 total points
ID: 12169051
The function name has been mangled by the C++ compiler to indicate what type its arguments are. This mangling is usually incompatable from one compiler to the next.

You need to get the other c++ programmer to declare his functions using the

extern "C"

construct. This will remove the mangling, and you will be able to easily use it.

0
 

Author Comment

by:blueyellowgreen
ID: 12169206
Thanks for the quick reply. I've sent your comment to the c++ programmer. Fingers crossed! :)
0
 
LVL 14

Expert Comment

by:wayside
ID: 12169331
I think they could also fix this by adding the relevant functions to the library's .def file:

EXPORTS
  TrackData=?TrackData@@YAHPAD@Z

This might be easier than changing the code to use extern "C".
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:blueyellowgreen
ID: 12169466
I've sent her that comment also. :)
0
 

Author Comment

by:blueyellowgreen
ID: 12182970
Hi,

The C++ programmer is still working on the DLL changes. As soon as the suggestions given above have been tried, I will be back to accept one of the suggestions or ask for more suggestions.

Thanks for you patience.  :)

0
 

Author Comment

by:blueyellowgreen
ID: 12216812
Wayside, The extern "C" worked like a charm! Thanks very much!!! :)
0
 
LVL 14

Expert Comment

by:wayside
ID: 12217187
Glad I could help! :)
0

Featured Post

Technology Partners: 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

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

623 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