Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2004-09-28
7
Medium Priority
?
220 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 2000 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
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!

 

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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
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. …
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.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

671 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