?
Solved

Cant find DLL reference point

Posted on 2000-02-23
3
Medium Priority
?
168 Views
Last Modified: 2012-05-04
I used C++ V6 to compile and link a DLL that includes function calls.  When I try to access functions from this DLL, I get the run-time error "Can't find DLL entry point ClfyConnect in notes2clarifydll".

I am thinking the problem is with the C++ DLL.

//////////////////////////
Sample calling code (VB6)...
Private Declare Function ClfyConnect Lib "notes2clarifydll" _
    (ByVal sServer As String, ByVal sDatabase As String, _
     ByVal sUsername As String, ByVal sPassword As String) As Long

////////////////////////////////
Sample C++ code generating the DLL...

__declspec(dllexport) long __stdcall ClfyConnect(char *,char *,char *,char *);
0
Comment
Question by:GregoryGr
  • 3
3 Comments
 
LVL 22

Accepted Solution

by:
nietod earned 400 total points
ID: 2551666
The problem is name decoration.  I have a "stock answer" I'll post it.
0
 
LVL 22

Expert Comment

by:nietod
ID: 2551678
C++ "decorates" or "mangles" function names by appending a "code" to the end of the name that expresses the parameters passed to the function.  This is used to impliment function overloading, where 2 or more distinct functions have the same name and different parameters.  (Apparently they have the same name--C++ mangles the names so they don't actually have the same name).  

The function is exported with the mangeled name, so you aren't actually specifying the right name in VB.  You can use dumpbin to verify this, you should see the function exported with a mangeled name and that is the name that you woudl have to specify to VB

To fix this problem, you can specify the mangeled name to VB, or--better--declared the function as "extern "C" ".  This dissables name mangeling on the function.

Let me know if you have questions.
0
 
LVL 22

Expert Comment

by:nietod
ID: 2551695
One more thing.  This may not be quite sufficient.  There is one other type of name decoration and this doesn't dissable that.  If after using extern "C" you find that the exported name (check with dumpbin) ends with a "@" followed by a number, they this is the standard call decoration.  

To remove this decoration you need to place an entry in the DLL's module defintion file (.def).  The entry should appear in the EXPORTS section and should just contain the name of the function.  for example

// in your .cpp file

extern "C" __declspec(dllexport) long __stdcall ClfyConnect(char *,char *,char *,char *);

// in your .def file.
EXPORTS
   ClfyConnect

let me know if you have any questions
0

Featured Post

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.

Question has a verified solution.

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

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
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 viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
Suggested Courses

809 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