Solved

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

Posted on 2004-09-28
7
216 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
  • 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
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
convert char array to number in c 5 86
Dynamically allocate memory 9 62
Best book to learn C++ 4 83
Error creating a new C++ project in ,net 20 41
Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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.

808 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