Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

importing functions from a dll

1 view
Skip to first unread message

roshini

unread,
Aug 9, 1998, 3:00:00 AM8/9/98
to
I am trying to import a function from a dll written in borland C++ in my
Visual C++ project.I included the library and the header file which has
the import dll statements , to the project but get a linker error saying
the lib file is corrupt or invalid(errorno LNK1136).
Can anyone help?
Thanks
Roshini

Larry Brasfield

unread,
Aug 9, 1998, 3:00:00 AM8/9/98
to
roshini wrote in message <35CDF273...@ee.tamu.edu>...

>I am trying to import a function from a dll written in borland C++ in my
>Visual C++ project.I included the library and the header file which has
>the import dll statements , to the project but get a linker error saying
>the lib file is corrupt or invalid(errorno LNK1136).

In general, binary compatibility between objects
created by different compilers is not assured.
C++ certainly does not guarantee that kind of
compatibility.

That said, your tools provide ways around the
problem. Look at docs for the linker and the
library creation options of the compiler(s).

You could also try Microsoft or Borland specific
newsgroups.

--Larry Brasfield
Above opinions may be mine alone.
(Humans may reply at unundered larry_br@sea_net.com )


Jim Shaw

unread,
Aug 10, 1998, 3:00:00 AM8/10/98
to
There are a few steps for linking in a Borland DLL to an MSVC project.

1) Use the Borland IMPDEF.EXE to create a DEF file from your DLL.
2) Use MSVC's LIB.EXE program to build an IMPORT library from the DEF file
created.
3) Link in this import library to your application.

At this point you may encounter linking problems (it depends upon the
Borland DLL's calling convention. If its cdecl then you should have no
problems. If its stdcall you'll have linker errors. Follow the following
steps to properly "map" the functions from MSVC expected stdcall syntax from
Borland's stdcall syntax.

Modify the Borland built DEF file by hand as follows:


<MSVC expected function name> = <Borland DEF file function name> <ordinal
value>

for example,

Borland.DEF file:

function1 @2
function2 @3

MSVC errors : unresolved functions

function1@32
function1@16

ModifyDEF file to map functions:

function1@32 = function1 @2
function1@16 = function2 @3

... etc...


Ciao!
Jim Shaw

roshini wrote in message <35CDF273...@ee.tamu.edu>...
>I am trying to import a function from a dll written in borland C++ in my
>Visual C++ project.I included the library and the header file which has
>the import dll statements , to the project but get a linker error saying
>the lib file is corrupt or invalid(errorno LNK1136).

0 new messages