Board index » cppbuilder » Problem linking VC++ DLL with BCB3

Problem linking VC++ DLL with BCB3

Help; I am at the limit of my knowledge!
I have been trying to link a proprietry 32 bit DLL written and created in
Digital Visual Fortran into a BCB3 exe by including the supplied .LIB file
in the project & all I get is 'idwm32.lib contains an invalid OMF record,
type 0x21'.

After a lot of grief with Microsoft Developer Studio, Visual Fortran & VC++,
I have concluded that the problem seems to be BCB3 inablility to link to a
Microsoft DLL.  I have created a small test DLL in VC++ with the following
function:    int _declspec(dllexport) _stdcall test() { return 1; }  which
also creates a .LIB file.  Trying to link this with BCB gives the same error
as above.  Ploughing on, I have then used IMPDEF & IMPLIB to create my own
.LIB files from the DLL.  The DLL no longer reports the earlier error but
gives  'Unresolved external 'test' referenced from ".../idwm.obj".  I have a
prototype
extern "C" { int _stdcall test(); } in my BCB file and the .DEF file
contains:
EXPORTS
    _test@0        =_test         @1

Can anyone please tell me what else I need to do?

I am seriously considering rewriting some of the Fortran source into C!

Please reply by e-mail
Malcolm

 

Re:Problem linking VC++ DLL with BCB3


On Thu, 20 Aug 1998 14:05:00 +0100, "Malcolm Hamer" <Malcolm.Ha...@bt.com>
wrote:

Quote
>as above.  Ploughing on, I have then used IMPDEF & IMPLIB to create my own
>.LIB files from the DLL.  The DLL no longer reports the earlier error but

That's what you need to do :-)

Quote
>gives  'Unresolved external 'test' referenced from ".../idwm.obj".  I have a
>prototype
>extern "C" { int _stdcall test(); } in my BCB file and the .DEF file
>contains:
>EXPORTS
>    _test@0        =_test         @1

Right.  There are a couple of problems here.

First, did you declare it as extern "C" in the VC++ version?  If not, you
need to do that as well.

Second, in BCB, the prototype needs to be
        extern "C" int _declspec(dllimport) _stdcall test();  

Third, you need to hand-edit the .DEF file to be
        test=_test@0
        (theBcbSymbol=theVC++Symbol)

Fourth, create an import library from the new .DEF

For the Fortran library, it should already be __stdcall, with naming
convention undecorated.  I would imagine that is you simply created an
import library from the FORTRAN DLL, that it would work, assuming, of
course, that the prototype in the BCB code is correct (with right calling
convention __stdcall, and extern "C")

+----------------------------------------------------------------------+
| Jody Hagins                                                          |
| Automated Trading Desk            "Fame is a vapor, popularity is an |
| 389 Johnnie Dodds Blvd, Su. 200   accident, and money takes wings.   |
| Mt. Pleasant, SC  29464           The only thing that endures is     |
| j...@atdesk.com                   character."                        |
|                                        - O.J. Simpson, 1979          |
+----------------------------------------------------------------------+

Re:Problem linking VC++ DLL with BCB3


Quote
> I have been trying to link a proprietry 32 bit DLL written and created in
> Digital Visual Fortran into a BCB3 exe by including the supplied .LIB file
> in the project & all I get is 'idwm32.lib contains an invalid OMF record,
> type 0x21'.

You can't use a static library made for VC++ (or any other compiler for
that matter).  Static libraries are not cross-compiler, for any number
of reasons, from naming conventions to internal structure differences.
Here's a short answer as found in the BCB Q&Q pages:

http://www.inprise.com/devsupport/bcppbuilder/qna/651.html

If it is an import library for a DLL, then you can roll your own.  Under
BCB3, there is a new utility called COFF2OMF that might do the trick.
You can also do it yourself using impdef and such.  A couple of pages
that are "Must See" for using VC++ DLLs:

http://www.pacifier.com/~jgibbon/program_tip_4.html
http://www.inprise.com/devsupport/bcppbuilder/qna/794.html

+===================================================+
| Jonathan Arnold (mailto:jdarn...@buddydog.org)    |
| Senior Engineer           Roger Wagner Publishing |
| http://people.ne.mediaone.net/jdarnold            |
+===================================================+

"In order to keep a true perspective of one's importance, everyone
 should have a dog that will worship him and a cat that will ignore
 him." -- Dereke Bruce

Other Threads