comp.lang.ada
 help / color / mirror / Atom feed
* Ada code -> DLL -> C++Builder3
@ 1999-08-29  0:00 Sean Parkinson
  1999-08-29  0:00 ` David Botton
  0 siblings, 1 reply; 2+ messages in thread
From: Sean Parkinson @ 1999-08-29  0:00 UTC (permalink / raw)


I have an application which is being built with
C++Builder Version 3 (it is using the latest
patch).  This application must use some Ada code.

I have an old DLL which was created by someone
else using Alsys ActivAda, and a newer DLL
(containing the same code) which I created using
Gnat Ada95.

Using the recently built DLL (from Gnat Ada95),
the MS QuickView listing shows a very small code
size of about 0x400h bytes, which is
unfortunately too much of a small rounded figure
to be realistic (it also doesn't alter with code
modification).

Using either the original DLL (compiled under
Alsys ActivAda 83), or the Gnat Ada95version, I
have performed the following...

[1] Produce an import library with IMPLIB
(resulting in a library file with extension .lib).
[2] Produce a module definition file with IMPDEF
(resulting in a definition file with extension
.def).
[3] Copy the X.DLL, X.DEF, and X.LIB files to the
code area for the C++ (if necessary).
[4] Ensure that there is a C/C++ header file with
the function prototypes for the items contained
within the DLL file.
[5] Add the X.LIB file to the C++Builder Project.
[6] Compile and link the C++Builder Project.

What this has resulted in (regardless of which
DLL I use), is a Windows executable which when
run from the IDE, command line, or Explorer
desktop, will cause an exception, or simply fail
to run (the code doesn't even reach the first
source line).

Having traced this through with the debugger, it
is my conclusion that the DLL is not being loaded
into memory at a correct location - thus
resulting in overwritten code or other DLL's
overwritten.  The cause of this seems a little
vague.  It will usually fail (depending upon
which other libraries are being used) at the
dynamic loading of the DLL in question (note that
I have tried statically linking the library).

I have looked through all the available options
within the C++Builder environment, with no
success in resolving this.

An interesting point worthy of note, is that
DLL's contain an "entry point", which facilitate
the initialisation (or elaboration) of the
function calls at runtime.  Windows uses the name
DllEntryPoint, whereas Ada uses a different name,
ada_dll_entry.  I have changed the Ada name to be
the same as the Windows name, to see if that
changes anything - with no success.

With both the original DLL and new DLL presenting
identical problems, and with them being produced
by two completely different Ada compilers, I
would tend to believe that this is a problem
within the C++Builder V3 product package suite
that either I am causing, or that C++Builder
itself is causing.

Has anybody got any ideas why this might be
happening, as I feel that I may have missed
something critical?

The DLLs will work correctly, when linked and run
with Ada code.

Any help you may be able to provide with the
above problem would be much appreciated.

Regards

Sean








^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Ada code -> DLL -> C++Builder3
  1999-08-29  0:00 Ada code -> DLL -> C++Builder3 Sean Parkinson
@ 1999-08-29  0:00 ` David Botton
  0 siblings, 0 replies; 2+ messages in thread
From: David Botton @ 1999-08-29  0:00 UTC (permalink / raw)


See the article:

* Using GNAT Dlls from C (van Dijk & Marceau)
http://www.adapower.com/articles

Also take a look at the other related articles there.

__Make sure you are calling AdaInit in the DllMain of the Ada DLL.__

David Botton


Sean Parkinson wrote in message <7qbftq$ntj$1@news7.svr.pol.co.uk>...
>Has anybody got any ideas why this might be
>happening, as I feel that I may have missed
>something critical?
>
>The DLLs will work correctly, when linked and run
>with Ada code.
>
>Any help you may be able to provide with the
>above problem would be much appreciated.
>
>Regards
>
>Sean







^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1999-08-29  0:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-08-29  0:00 Ada code -> DLL -> C++Builder3 Sean Parkinson
1999-08-29  0:00 ` David Botton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox