?
Solved

Cant find DLL reference point

Posted on 2000-02-23
3
Medium Priority
?
165 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
[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
  • 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

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

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…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

801 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