Unfortunately, I don't have the *.LIB file associated with this
particuluar *.DLL file. I've looked through the DLL file with a
text-editor and I'm sure I know the names of the enclosed functions.
Anyway, I created a bogus C++ project to declare these function names
(the project is targeted to a DLL.) This "bogus" DLL compiles
successfully (and yields the complimentary LIB file for inclusion in
other projects), *but* it seems that Borland C++ performs name-mangling
on the DLL's member-functions. For example, a text-search of the real
DLL (the one I'm trying to link up with) reveals these function names
"GetUser", "DropUser" If I compile my Win32 console program, using
the LIB file I bogusly generated, then attempt to execute the app
with the real DLL file, the application aborts with the error:
"Cannot resolve @GetUser$qve" (that's the first function I call)
^^^^
Ok, how do I prevent Borland C++ from appending these extra
characters? (By the way, I also tried running my win32 console app
with the DLL that I generated, it works properly. However, I wanted to
practice linking with a foreign DLL!)
First, Borland's compilers come with a tool to build .LIB files from
..DLL files. Look for Implib in your tools documentation.
Second, you can tell Borland C++ (or nearly any other C++ compiler) not
to do name mangling by declaring your functions as extern "C"; for
example:
extern "C" void GetUser(char* strName);
or:
extern "C" {
void GetUser(char* strName);
void DropUser(char* strName);
}
You can also combine extern "C" with PASCAL:
extern "C" void PASCAL GetUser(char* strName);
The above would give you a reference to an external symbol GETUSER. If
your DLL really contains mixed case names like GetUser you will probably
have to specifiy a case-insensitive link.
Norm
Anonymous wrote in message <34E900...@nowhere.com>...
>I'm a newbie programmer and I don't know much about Windows
>programming. I'm writing a simple Win32 console program to access some
>functions inside a .DLL file. According to the windows-programming book
>that I've consulted, I need to include a *.LIB file in my C++ project
>environment, so the Borland linker can properly resolev the function
>calls (parameters and what not.)
>
>Unfortunately, I don't have the *.LIB file associated with this
>particuluar *.DLL file. I've looked through the DLL file with a
>text-editor and I'm sure I know the names of the enclosed functions.
>
>Anyway, I created a bogus C++ project to declare these function names
>(the project is targeted to a DLL.) This "bogus" DLL compiles
>successfully (and yields the complimentary LIB file for inclusion in
>other projects), *but* it seems that Borland C++ performs name-mangling
>on the DLL's member-functions.
> ....
You can try to declare your functions inside an extern "C" block. In
microsoft VC++ you can avoid name mangling if you give C extension to your
file instead of CPP default but I don't know if Borland support this.
I had a freeware utility called IMPLIB32 that generates .LIB files form DLLs
(like the old 16bit IMPLIB) and you should find it on many
freeware/shareware websites.
---
Valter Minute
min...@fortech.it (the reply address is invalid to avoid spam-mail)
www.fortech.it/english
---
Are you looking for a good freeware ScreenSaver? Try FOYD!
http://www.winsite.com/info/pc/win95/desktop/foyd1295.zip/
And ask me for the free C++ source code.
I will try the "IMPLIB" utility, just curious, why is IMPLIB not
cross-referenced inside Borland C++ 5.02's online documentation?
(I guess I didn't know the right place to look.) Well, at least
Borland C++ 5.02 comes with SOME hard copy documentation, unlike
certain Microsoft products (Visual C++ 5.0 Pro)
I did notice that the linker could only find the functions (inside
the imported LIB file from the foreign DLL) if the following
conditions were true :
32-bit Compiler option set to "Standard call" ( the
default was C calling convention )
The imported functions were declared inside my cpp source as
extern "C" DLLImport DWORD getuser( DWORD )
^^^^^^^^^^ ("DLLImport" is a preprocessor macro that I
declared to save work...I actualy took the code
from a Visual C++ book!)
My next question is...how do I use Borland C++ to replicate these
function calls in a DLL? Thanks to the Visual C++ book, I already
know how to create and compile DLL files within Borland C++.
Unfortunately, the DLL file's functions don't conform to the
function-prototypes I've shown above. If I remove the "extern C"
prefix, then I can link with my own compiled DLL (but not the
foreign-DLL.)
I apologize for the terseness of my post. I'm hopng I just mised
something simple and easy. In the DLL project I've created, i
tried declaring the DLL functions with extern "C", __stdcall,
__cdecl, etc. none seem to help! is there a simple switch?