Link to home
Start Free TrialLog in
Avatar of SeanR
SeanR

asked on

Unresolved external in BC 5.01

I'm trying to convert a 16-bit dll to 32-bit. The dll uses an ojbect file that I created using MASM 6.11c. I compiled the ASM file and have a new 32-bit .OBJ file. It compiled with no errors. The relevent part of the ASM file follows:

.386
.model flat, stdcall      
.CODE
M250    PROC   NEAR COMMAND:DWORD, L_RESPONSE:DWORD, RET_ERROR:DWORD

In the header file for the dll, I have the following line to define the prototype for M250:

extern "C"
{
  BOOL __stdcall M250(short *command, long *response, short
*errorCode);
}

The TargetExpert options are Platform:Win32 and Target Model: Console.

And the IDE project looks like this:

250dll32 {.dll]
   |
   250dlld [.cpp]
   |
   |--250dll [.h]
   |
   M250_32  [.obj]
   |
   default  [.def]


When I attempt to build the dll. I get the following message

Info :Building...
Info :Compiling C:\Model250\250ewin\version5\32bit\250dlld.cpp
Info :Linking C:\Model250\250ewin\version5\32bit\250dll32.dll
Warn :  Warning: .DEF file heap reserve size < 64K; 1MB default will be used
Warn :  Warning: .DEF file stack reserve size < 64K; 1MB default will be used
Error:  Error: Unresolved external 'M250' referenced from module 250dlld.cpp

What am I doing wrong? The project compiles and runs fine when I built it for 16-bit.
ASKER CERTIFIED SOLUTION
Avatar of chedrick
chedrick

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of SeanR
SeanR

ASKER

I dropped the NEAR. No change, still unresolved external 'M250'.
Opps, I answer so many of these sometimes I forget and submit an incomplete answer. Sorry about that {:-)
In Win32 a short is two bytes and a long is four The compiler is trying to resolve a M250 with a short int, a long and another short int as arguments. You function has DWORD,DWORD,DWORD.
Adjust one or the other to match and this should go away (the key work here is should...)
If not, let me know...

Happy linkin'
Chuck
Any by the way... pointers (like those your function uses) are 32 bit addresses (that 4 bytes to you and me) so try changing the prototype to
M250(DWORD command, DWORD response, DWORD *errorCode);
and see if it resolves. If so the problem is definitely in the declaration.

That declaration should end with DWORD errorCode);
NOT
DWORD *errorCode);
Sorry, too much tube time...

Chuck
Sean,
One final suggestion...
I typically use WINAPI (the same as FAR PASCAL) for exported DLL functions in Win32. I don't *think* this is the problem but if the above suggestions fail, try it.

Chuck...
Avatar of SeanR

ASKER

Sorry for the delay, I've been working on another project.
I have tried the suggestions given above, and I still get "unresolved external 'M250'". Could someone give me an example of a MASM assembly function that takes three arguments by reference in 32-bit code, and the calling declaration in C for Borland C++ 5.01?