Board index » delphi » Mixed language programming (C/C++ with Delphi)

Mixed language programming (C/C++ with Delphi)

Does anyone know if its possible to do mixed language programming with Delphi.
Such as mixing Borland C/C++ modules with Delphi modules in a project vs a DLL
or VBX at runtime?

We have some thorney problems which could be easly solved if it is possible to
add Borland C modules.

Thanks in advance

/*************************************************************
 Dave Mandala      Them Productions       San Francisco, CA
 Internet: da...@them.com CIS: 74156,221  AOL: dism
*************************************************************/

 

Re:Mixed language programming (C/C++ with Delphi)


Yes, it's perfectly possible, and in fact very easy.

You can use C++ DLL's in Delphi, V1.0 VBX's in Delphi, the main thing
you can't do is to mix code or object modules (not a great problem).

It's been rumoured that Delphi 32 will link .OBJ files from Borland
C++.

Quote
dav...@them.com (David Mandala) wrote:
>Does anyone know if its possible to do mixed language programming with Delphi.
>Such as mixing Borland C/C++ modules with Delphi modules in a project vs a DLL
>or VBX at runtime?

>We have some thorney problems which could be easly solved if it is possible to
>add Borland C modules.

>Thanks in advance

>/*************************************************************
> Dave Mandala      Them Productions       San Francisco, CA
> Internet: da...@them.com CIS: 74156,221  AOL: dism
>*************************************************************/

Re:Mixed language programming (C/C++ with Delphi)


In specific, I'm wondering if one can directly link  modules and NOT use DLL's
or VBX's.  Both DLL's and VBX's have some drawbacks that are not encountered
in a compile time link.

In article <30d07ff6.319...@news.demon.co.uk>,
   ca...@larouss.demon.co.uk (Casey Charlton) wrote:

Quote
>Yes, it's perfectly possible, and in fact very easy.

>You can use C++ DLL's in Delphi, V1.0 VBX's in Delphi, the main thing
>you can't do is to mix code or object modules (not a great problem).

>It's been rumoured that Delphi 32 will link .OBJ files from Borland
>C++.

>dav...@them.com (David Mandala) wrote:

>>Does anyone know if its possible to do mixed language programming with
Delphi.
>>Such as mixing Borland C/C++ modules with Delphi modules in a project vs a
DLL
>>or VBX at runtime?

>>We have some thorney problems which could be easly solved if it is possible
to
>>add Borland C modules.

>>Thanks in advance

>>/*************************************************************
>> Dave Mandala      Them Productions       San Francisco, CA
>> Internet: da...@them.com CIS: 74156,221  AOL: dism
>>*************************************************************/

/*************************************************************
 Dave Mandala      Them Productions       San Francisco, CA
 Internet: da...@them.com CIS: 74156,221  AOL: dism
*************************************************************/

Re:Mixed language programming (C/C++ with Delphi)


Quote
ca...@larouss.demon.co.uk (Casey Charlton) wrote:
>In Delphi 32 - allegedly Borland C++ OBJ files can be linked.
>Otherwise NO.

The {$L filename} compiler-option and the external directive lets you link to
any Intel relocatable object module format file (.OBJ), so I don't think the
above is correct. C++ compilers each have thier own name-mangling schemes so
you'll be restricted to non-C++ code.
Quote
>dav...@them.com (David Mandala) wrote:
>>In specific, I'm wondering if one can directly link  modules and NOT use DLL's
>>or VBX's.  Both DLL's and VBX's have some drawbacks that are not encountered
>>in a compile time link.

Re:Mixed language programming (C/C++ with Delphi)


In Delphi 32 - allegedly Borland C++ OBJ files can be linked.
Otherwise NO.
Quote
dav...@them.com (David Mandala) wrote:
>In specific, I'm wondering if one can directly link  modules and NOT use DLL's
>or VBX's.  Both DLL's and VBX's have some drawbacks that are not encountered
>in a compile time link.

Re:Mixed language programming (C/C++ with Delphi)


You will be able to use C/C++ OBJ files and link them into Delphi in the
upcoming version slated for release in Q196. This is the word from Borland. They
will be using the EXACT back-end compiler for both language products. In fact,
Delphi 32 will be able to produce OBJ files which you can subsequently link into
your C++ projects. Quite nifty.

Brendan

Quote
dav...@them.com (David Mandala) wrote:
>In specific, I'm wondering if one can directly link  modules and NOT use DLL's
>or VBX's.  Both DLL's and VBX's have some drawbacks that are not encountered
>in a compile time link.
>In article <30d07ff6.319...@news.demon.co.uk>,
>   ca...@larouss.demon.co.uk (Casey Charlton) wrote:
>>Yes, it's perfectly possible, and in fact very easy.

>>You can use C++ DLL's in Delphi, V1.0 VBX's in Delphi, the main thing
>>you can't do is to mix code or object modules (not a great problem).

>>It's been rumoured that Delphi 32 will link .OBJ files from Borland
>>C++.

>>dav...@them.com (David Mandala) wrote:

>>>Does anyone know if its possible to do mixed language programming with
>Delphi.
>>>Such as mixing Borland C/C++ modules with Delphi modules in a project vs a
>DLL
>>>or VBX at runtime?

>>>We have some thorney problems which could be easly solved if it is possible
>to
>>>add Borland C modules.

>>>Thanks in advance

>>>/*************************************************************
>>> Dave Mandala      Them Productions       San Francisco, CA
>>> Internet: da...@them.com CIS: 74156,221  AOL: dism
>>>*************************************************************/

>/*************************************************************
> Dave Mandala      Them Productions       San Francisco, CA
> Internet: da...@them.com CIS: 74156,221  AOL: dism
>*************************************************************/

"...an obsession with process will create a
      myopia that discourages people from testing
         assumtions and engaging in breakthrough thinking."
                                 -Patricia McLagan

Re:Mixed language programming (C/C++ with Delphi)


I do not believe that you can link object models from Delphi to
Borland C++ in the 16 bit version of Delphi.

HOWEVER, I just read an article on Delphi 32 and Borland has moved
Delphi over to the same compiler Engine that Borland C++ uses with the
idea that you could directly use OBJ modules from C++ in Delphi and
vice versa.

They have slated the release of Delphi 32 for the first half of 1996.

Hope this helps,
Allen

Quote
dav...@them.com (David Mandala) wrote:
>In specific, I'm wondering if one can directly link  modules and NOT use DLL's
>or VBX's.  Both DLL's and VBX's have some drawbacks that are not encountered
>in a compile time link.
>In article <30d07ff6.319...@news.demon.co.uk>,
>   ca...@larouss.demon.co.uk (Casey Charlton) wrote:
>>Yes, it's perfectly possible, and in fact very easy.

>>You can use C++ DLL's in Delphi, V1.0 VBX's in Delphi, the main thing
>>you can't do is to mix code or object modules (not a great problem).

>>It's been rumoured that Delphi 32 will link .OBJ files from Borland
>>C++.

>>dav...@them.com (David Mandala) wrote:

>>>Does anyone know if its possible to do mixed language programming with
>Delphi.
>>>Such as mixing Borland C/C++ modules with Delphi modules in a project vs a
>DLL
>>>or VBX at runtime?

>>>We have some thorney problems which could be easly solved if it is possible
>to
>>>add Borland C modules.

>>>Thanks in advance

>>>/*************************************************************
>>> Dave Mandala      Them Productions       San Francisco, CA
>>> Internet: da...@them.com CIS: 74156,221  AOL: dism
>>>*************************************************************/

>/*************************************************************
> Dave Mandala      Them Productions       San Francisco, CA
> Internet: da...@them.com CIS: 74156,221  AOL: dism
>*************************************************************/

Re:Mixed language programming (C/C++ with Delphi)


(Ok, I'll prefix my text too, on this one)

The problem with direct linking {$L yourproc.obj} is that any
significant C/C++ function/procedure is almost certain to be
calling run-time library functions and/or certain little helper
routines that support the compiler generated code, but aren't
documented standard library items like open() or sin() or such.

So even if you could supply Delphi routines for the big standard
externals, you stand a good chance of running aground on things
like stack checks, longint arithmetic routines with totally
non-standard calling sequences that may be jumps into assembly
language spaghetti code to different places depending on which
registers happen to have partial results of an expression in
them, and so forth. If you had the sources for that stuff, or are
able sto extract the right .objs from the libraries, conceivably
you could {$L crtlfrag.obj} for those things, but what about
floating point run time support? The exceptions, emulator support?
You can't interrupt to two places at once. Would you try to switch
FP support as you entered and exited the c/c++ stuff? A DLL solves
all that (although now that I mention it, I'm not sure how the
floating point interrupts might be handled in a C DLL...maybe it's
best to have on-chip floating point and no errors :-). Anyway, a DLL
solves most of that run-time library problem by creating a black box
with a well defined interface and all support stuff resolved
internally.
  Another problem may be incompatibilities in the .obj format. The
linker may just {*word*88} on something from MicroSoft, for example, unless
it's compiled with all special stuff turned off. It's supposed to be
an Intel standard, but when it comes to including debug information,
and some special stuff, there can be differences. Also in the use of
data and code segment names and attributes.
  As Casey mentioned, though, there's hope that Borland's move to
common code generator for Delphi32 and BCCPx should mean they share
run time support libraries (or at least use modules that can live
side by side), so if you get the right versions of those tools, and
recompile, you should be able to link the result directly.

In the meanwhile, unless you have an unusually pure and independent
set of subroutines, I would go the DLL route. If they're that pure
and simple, they'll be extra easy to encapsulate in a dll too.

If your sources are C++ rather than C, and actually make use of
C++ classes etc., then you about have to go the DLL route. Unless
it's been designed to play together, it is not likely to.

HTH,
Regards,
Bengt Richter
------------------------------------------------------------------

Quote
dav...@them.com (David Mandala) wrote:
>In specific, I'm wondering if one can directly link  modules and NOT use DLL's
>or VBX's.  Both DLL's and VBX's have some drawbacks that are not encountered
>in a compile time link.
>In article <30d07ff6.319...@news.demon.co.uk>,
>   ca...@larouss.demon.co.uk (Casey Charlton) wrote:
>>Yes, it's perfectly possible, and in fact very easy.

>>You can use C++ DLL's in Delphi, V1.0 VBX's in Delphi, the main thing
>>you can't do is to mix code or object modules (not a great problem).

>>It's been rumoured that Delphi 32 will link .OBJ files from Borland
>>C++.

>>dav...@them.com (David Mandala) wrote:

>>>Does anyone know if its possible to do mixed language programming with
>Delphi.
>>>Such as mixing Borland C/C++ modules with Delphi modules in a project vs a
>DLL
>>>or VBX at runtime?

>>>We have some thorney problems which could be easly solved if it is possible
>to
>>>add Borland C modules.

>>>Thanks in advance

>>>/*************************************************************
>>> Dave Mandala      Them Productions       San Francisco, CA
>>> Internet: da...@them.com CIS: 74156,221  AOL: dism
>>>*************************************************************/

>/*************************************************************
> Dave Mandala      Them Productions       San Francisco, CA
> Internet: da...@them.com CIS: 74156,221  AOL: dism
>*************************************************************/

Re:Mixed language programming (C/C++ with Delphi)


I've tried to do this in the past.. The problem I had was debug. If you have access
to a debug solution that will allow you to get at both the Delphi code, and the C
code, it shouldn't be a problem. BTW, if anyone knows of a de{*word*81} that can deal
with this, I would appreciate some email...

Mike

Other Threads