Board index » delphi » Linking VC++ obj files with Delphi

Linking VC++ obj files with Delphi

Hi,

I have some C++ source code that I'd like to reuse in Delphi, without
needing to rewrite it and without using DLLs.

So what I've done is I've compiled the C++ file (using Microsoft Visual C++)
and tried to link it in Delphi 5:

{$L mylib.obj}

procedure myfunction; extern;

This doesn't work ... Delphi says the object file format is wrong. I've
tried to use extern "C" and stdcall, but that didn't help. Does VC++ create
nonstandard object files? Or did I miss something?

Please cc replies to jrsoftware@NOS...@planet-interkom.de (obviously, remove
@NOSPAM :-)

Thanks,

J?rg

 

Re:Linking VC++ obj files with Delphi


Jorg:

I tried to do this a few months ago.  VC doesn't use a 'nonstandard'
obj format, but a different one.  In fact, I believe the borland obj
format is the more non-standard one.

I ended up including the VC obj in a VC dll and calling that from
delphi - which you say you don't want to do.  Possible alternatives:

a. create pascal wrappers for the C functions you want to use.

b. try to compile the VC source with a borland C compiler to generate
a borland obj file.

The above I believe to be true but I'm certanly no C expert and there
may be a better alternative.

HC

On Wed, 22 Mar 2000 16:11:46 +0100, "Joerg Rathlev"

Quote
<jrsoftware@NOS...@planet-interkom.de> wrote:
>Hi,

>I have some C++ source code that I'd like to reuse in Delphi, without
>needing to rewrite it and without using DLLs.

>So what I've done is I've compiled the C++ file (using Microsoft Visual C++)
>and tried to link it in Delphi 5:

>{$L mylib.obj}

>procedure myfunction; extern;

>This doesn't work ... Delphi says the object file format is wrong. I've
>tried to use extern "C" and stdcall, but that didn't help. Does VC++ create
>nonstandard object files? Or did I miss something?

>Please cc replies to jrsoftware@NOS...@planet-interkom.de (obviously, remove
>@NOSPAM :-)

>Thanks,

>J?rg

Other Threads