PDA

Click to See Complete Forum and Search --> : Creating Dlls (w/ Borland 5.02)


redbird77
Sep 27th, 2000, 07:32 PM
Hi,

I've been trying to creating a simple (like adding two numbers or concatenating two strings) dll to use in VB.

Of course, I try to do the most amount of stuff with the least amount of knowledge ;-) So _detailed_ step-by-step instructions would be nice.

So far I've managed to...

- create a project (in Borland 5.02 not VC)
- make the target a .dll file
- add a .cpp and .h file with one function
- add a .def file with the text
EXPORTS
FunctionName

Tried to make the dll got an error like ...unresolved reference from the root... or something like that.


I bet I'm going about this all wrong so any advice/actual source code would be appreciated.

Amanda

parksie
Sep 29th, 2000, 05:12 PM
Could you post your code? I'll take a look at it for you.

redbird77
Oct 1st, 2000, 01:11 AM
Hi again,

I read a couple of replies on this board and realized I was missing the crucial "__declspec(dllexport)" bit.

When I added this to the function, I was able to create a dll that worked in VB.

Yet when I compiled the dll I got a message that said "Failure" and in the message window (in Borland) it said

"Info :Transferring to C:\PROGRAM FILES\BC5\BIN\implib.exe @c:\windows\TEMP\RSP0.$$$"

I don't know enough to know what this means, and I find it strange that despite a "Failure" message, that the dll seems to work fine.

Any insight would be appeciated,
Amanda

P.S. Here's my code

vb_prac.cpp
-----------
extern "C" __declspec(dllexport) int _stdcall MyAdd(int a, int b)
{
return a + b;
}

vb_prac.def
-----------
EXPORTS
MyAdd

parksie
Oct 1st, 2000, 04:28 AM
I can't see why that would make a difference, since __declspec(dllexport) is designed as a replacement for the .def file.
If you omit the .def file from your compilation, it should still work.

(Since I don't have BC I can't give any help on the "Failure" message...)