comp.lang.ada
 help / color / mirror / Atom feed
* C++ to Ada Link Problems
@ 1998-02-25  0:00 James Huckaby
       [not found] ` <9802270246.AA28724@MERV.CS.NYU.EDU>
  0 siblings, 1 reply; 11+ messages in thread
From: James Huckaby @ 1998-02-25  0:00 UTC (permalink / raw)



I've been trying to link Ada to C++ using SUN Ada 2.1 and
SUN C++ 3.0 without any luck.  I have a thin C interface and
most of my functionality works, but I'm hitting the wall
when it comes to all of the C++ pre-initialized things.  From
reading past C++ to Ada discussions (Dejanews) it seems that
there is a way to preinitialize the C++ data stuff but I could
find no details.  

Any help would be appreciated.

''``''``''``''``''``''``''``''``''``''``''``''``''``''``''``''
James Huckaby                  mailto:James.B.Huckaby@LMCo.com
''``''``''``''``''``''``''``''``''``''``''``''``''``''``''``''
``''``''``''``''``''``''``''``''``''``''``''``''``''``''``''``




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

* Re: C++ to Ada Link Problems
  1998-02-27  0:00     ` James Huckaby
@ 1998-02-27  0:00       ` Stanley R. Allen
  1998-02-28  0:00       ` Simon Wright
  1 sibling, 0 replies; 11+ messages in thread
From: Stanley R. Allen @ 1998-02-27  0:00 UTC (permalink / raw)
  To: James.B.Huckaby


James Huckaby wrote:
> 
> 
> I think I might be able to redirect the a.ld command to
> use CC instead of ld (it will probably be trial and error
> for awhile).

The easiest way to do this is to use the -V option
on the a.ld command.  This will "verify" the ld
command to be used without executing it (lower case
-v will display the ld command, and execute it).

I'm not sure it it goes to sdtout or sdterr; try
and see.  Then edit to use CC instead of ld.

> Do you have any examples of munchers
> or munching tools?

The only munching tools I know of are part of the
GNU suite that comes with the VxWorks system I am
using.  I was assuming that this is part of the
GNU standard toolset.  If Sun C++ doesn't have
such a tool then the comments about munching
probably don't apply to your problem.

-- 
Stanley Allen
mailto:s_allen@hso.link.com




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

* Re: C++ to Ada Link Problems
  1998-02-27  0:00   ` Larry Kilgallen
@ 1998-02-27  0:00     ` Robert Dewar
  1998-02-28  0:00       ` Larry Kilgallen
  0 siblings, 1 reply; 11+ messages in thread
From: Robert Dewar @ 1998-02-27  0:00 UTC (permalink / raw)



Larry said

<commercial for GNAT snipped>


I quite agree that this was an inappropriate commercial, which is why I
had sent it as personal email, it was forwarded without my permission.

There is certainly nothing secret about the message, but I try to be
aware of an appropriate line between appropriate posts and commercials :-)
My own feeling is that commercial announcements of new products etc are
fine for CLA, but one has to be careful about advocacy!

Robert Dewar
Ada Core Technologies





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

* Re: C++ to Ada Link Problems
  1998-02-27  0:00 ` C++ to Ada Link Problems James Huckaby
@ 1998-02-27  0:00   ` Robert Dewar
  1998-02-27  0:00   ` Stanley R. Allen
  1998-02-27  0:00   ` Larry Kilgallen
  2 siblings, 0 replies; 11+ messages in thread
From: Robert Dewar @ 1998-02-27  0:00 UTC (permalink / raw)



James quoted me as saying

<<Robert Dewar wrote:
 Even if you have to use Ada 83, you will find that it is MUCH easier
 to do this in GNAT, which fully supports Ada 83. Note that there is NO
 portable way of doing what you want AT ALL in Ada 83, so if your
 requirement is to do this in standard Ada 83 in a portable manner, you
 can pack up your tools now, it is impossible. Only Ada 95 begins to
 standardize such interfacing.

 But given that you have to write it in implementation dependent Ada 83,
 you would indeed NOT have a notoriously difficult time of it with GNAT.
 Not only is GNAT far better technically suited to the task, but you would
 get the kind of support from its vendor that you need, instead of having
 to resort to the last-chance-desperation of hoping that someone among the
 dwindling number of knowledgable contributors to Comp.Lang.Ada helps you.
 (the amount of complete nonsense in posts to this group published as if
 by experts who know what they are talking about is alarming, as is the
 decrease in the frequency with which such nonsense posts are corrected).
>

I wrote this as personal email, which James forwarded to CLA. I sent it
as email because I considered that it had too much of a commercial message
to be appropriate for CLA. No harm done, but I wanted it to be clear what
happened here!

Robert Dewar
Ada Core Technologies





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

* Re: C++ to Ada Link Problems
       [not found] <9802271359.AA07254@nile.gnat.com>
@ 1998-02-27  0:00 ` James Huckaby
  1998-02-27  0:00   ` Robert Dewar
                     ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: James Huckaby @ 1998-02-27  0:00 UTC (permalink / raw)
  To: Robert Dewar


Robert Dewar wrote:
> Even if you have to use Ada 83, you will find that it is MUCH easier
> to do this in GNAT, which fully supports Ada 83. Note that there is NO
> portable way of doing what you want AT ALL in Ada 83, so if your
> requirement is to do this in standard Ada 83 in a portable manner, you
> can pack up your tools now, it is impossible. Only Ada 95 begins to
> standardize such interfacing.
> 
> But given that you have to write it in implementation dependent Ada 83,
> you would indeed NOT have a notoriously difficult time of it with GNAT.
> Not only is GNAT far better technically suited to the task, but you would
> get the kind of support from its vendor that you need, instead of having
> to resort to the last-chance-desperation of hoping that someone among the
> dwindling number of knowledgable contributors to Comp.Lang.Ada helps you.
> (the amount of complete nonsense in posts to this group published as if
> by experts who know what they are talking about is alarming, as is the
> decrease in the frequency with which such nonsense posts are corrected).

Unfortunately, I have to link to ada libraries given to us by a
contractor
that are done using Sun Ada 2.1 as well.  Despite that our contract
requires
that we use commercially supported software.  To top that off, I
personally
have nothing to do with software installation, choices, et al, but have
been
informed by our person in that area that GNAT is not an option. (Which
he
also regrets and says that if we had the option we would have already
jumped
on it)

Simply put, is it at all possible with the resources I have now (Sun Ada
2.1
and Sun C++ 3.0, upgrading soon to Sun Ada 3.0, and Sun C++ 4.0) to link
Ada and C++?

''``''``''``''``''``''``''``''``''``''``''``''``''``''``''``''
James Huckaby                  mailto:James.B.Huckaby@LMCo.com
''``''``''``''``''``''``''``''``''``''``''``''``''``''``''``''
``''``''``''``''``''``''``''``''``''``''``''``''``''``''``''``




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

* Re: C++ to Ada Link Problems
  1998-02-27  0:00 ` C++ to Ada Link Problems James Huckaby
  1998-02-27  0:00   ` Robert Dewar
@ 1998-02-27  0:00   ` Stanley R. Allen
  1998-02-27  0:00     ` James Huckaby
  1998-02-27  0:00   ` Larry Kilgallen
  2 siblings, 1 reply; 11+ messages in thread
From: Stanley R. Allen @ 1998-02-27  0:00 UTC (permalink / raw)



James Huckaby wrote:
> 
> 
> Simply put, is it at all possible with the resources I have now
> (Sun Ada 2.1 and Sun C++ 3.0, upgrading soon to Sun Ada 3.0, and
> Sun C++ 4.0) to link Ada and C++?

"Linking C++ and Ada" is an umbrella topic.  You might mean
by this that you need to "interface" Ada and C++.  If so, you
may need to set up some C code which calls the C++ code,
and interface the Ada to this using pragma Interface.

But by the wording of your question, I suppose that you
have alreasy worked out those issues and are trying now
to build an executable.  The main issue is C++ constructor/
deconstructor ("Xtor") operations for statically-declared
object instances: how do they get called?  In Ada, global
variable initialization is defined in the language as
part of the elaboration process.  In C++, it is the
job of external tools.  A common way of creating the
contructor/destructor caller is to "munch" the object
code produced by the C++ compiler (using a munching
tool), which will produce a C file that calls the
Xtors.  Compiling this C file and linking the new
object module with the C++ code will ensure that the
C++ static objects are constructed properly.  To link
with Ada, ensure that the object file created from
the C program is included as one of the inputs to the
linker building the Ada main.  (Since you are talking
about Ada 83, I assume that the main program is in Ada.)
My understanding is that munching is the approach
used by the GNU C++ implementation.

Other C++ compilers don't require a separate munching
phase, but expect that the linker will include calls
to the proper contructor/destructors.  If the Ada
binding program (I think that would be a.ld for SunAda)
is used to create the Unix "ld" command, then the
stuff C++ needs will not be included.  I'm not sure how
it works on the Sun; on the SGI with Delta C++ you can
specify that the C++ compiler itself ("CC") be used as
the linker.  This will include the necessary code to
call the Xtor operations for static C++ objects.

Disclaimer: I have only done the above with GNAT, but
I believe the same principles apply when linking code
produced by other Ada compilers.  

-- 
Stanley Allen
mailto:s_allen@hso.link.com




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

* Re: C++ to Ada Link Problems
  1998-02-27  0:00 ` C++ to Ada Link Problems James Huckaby
  1998-02-27  0:00   ` Robert Dewar
  1998-02-27  0:00   ` Stanley R. Allen
@ 1998-02-27  0:00   ` Larry Kilgallen
  1998-02-27  0:00     ` Robert Dewar
  2 siblings, 1 reply; 11+ messages in thread
From: Larry Kilgallen @ 1998-02-27  0:00 UTC (permalink / raw)



In article <34F6CC30.D8B74ACB@mps.lmtas.lmco.com>, James Huckaby <jhuckaby@mps.lmtas.lmco.com> writes:

<commercial for GNAT snipped>

> Unfortunately, I have to link to ada libraries given to us by a
> contractor
> that are done using Sun Ada 2.1 as well.  Despite that our contract
> requires
> that we use commercially supported software.

As Robert will point out if I don't beat him to it (and maybe anyway :-),
ACT is in the _business_ of providing commercial support for GNAT.

Not being an ACT customer, I cannot say how good their support is,
but from your description it would seem that ACT would be incapable
of providing worse support than you are getting from Sun.

Larry Kilgallen




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

* Re: C++ to Ada Link Problems
  1998-02-27  0:00   ` Stanley R. Allen
@ 1998-02-27  0:00     ` James Huckaby
  1998-02-27  0:00       ` Stanley R. Allen
  1998-02-28  0:00       ` Simon Wright
  0 siblings, 2 replies; 11+ messages in thread
From: James Huckaby @ 1998-02-27  0:00 UTC (permalink / raw)
  To: Stanley R. Allen


Stanley R. Allen wrote:
> But by the wording of your question, I suppose that you
> have alreasy worked out those issues and are trying now
> to build an executable.  The main issue is C++ constructor/
> deconstructor ("Xtor") operations for statically-declared
> object instances: how do they get called?  In Ada, global
> variable initialization is defined in the language as
> part of the elaboration process.  In C++, it is the
> job of external tools.  A common way of creating the
> contructor/destructor caller is to "munch" the object
> code produced by the C++ compiler (using a munching
> tool), which will produce a C file that calls the
> Xtors.  Compiling this C file and linking the new
> object module with the C++ code will ensure that the
> C++ static objects are constructed properly.  To link
> with Ada, ensure that the object file created from
> the C program is included as one of the inputs to the
> linker building the Ada main.  (Since you are talking
> about Ada 83, I assume that the main program is in Ada.)
> My understanding is that munching is the approach
> used by the GNU C++ implementation.
> 
> Other C++ compilers don't require a separate munching
> phase, but expect that the linker will include calls
> to the proper contructor/destructors.  If the Ada
> binding program (I think that would be a.ld for SunAda)
> is used to create the Unix "ld" command, then the
> stuff C++ needs will not be included.  I'm not sure how
> it works on the Sun; on the SGI with Delta C++ you can
> specify that the C++ compiler itself ("CC") be used as
> the linker.  This will include the necessary code to
> call the Xtor operations for static C++ objects.

I think I might be able to redirect the a.ld command to
use CC instead of ld (it will probably be trial and error
for awhile).  Do you have any examples of munchers
or munching tools?  I did a Yahoo! search and it was
very fascinated about the wrong sort of munching and
the painter Muench. (ue = u umlaut)

''``''``''``''``''``''``''``''``''``''``''``''``''``''``''``''
James Huckaby                  mailto:James.B.Huckaby@LMCo.com
''``''``''``''``''``''``''``''``''``''``''``''``''``''``''``''
``''``''``''``''``''``''``''``''``''``''``''``''``''``''``''``




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

* Re: C++ to Ada Link Problems
       [not found] ` <9802270246.AA28724@MERV.CS.NYU.EDU>
@ 1998-02-27  0:00   ` James Huckaby
  0 siblings, 0 replies; 11+ messages in thread
From: James Huckaby @ 1998-02-27  0:00 UTC (permalink / raw)
  To: Robert Dewar


Robert Dewar wrote:
> 
> You will find that the problems of interfacing to C and C++ are FAR
> simpler using Ada 95 in general, and GNAT in particular. I suggest
> giving consideration to this alternative. Ada 83 systems tend to be
> notoriously difficult to interface to C++.

Well, I've been having a notoriously difficult time of it, but
I'm limited due to contracts and contractors.  I have to use
Ada 83.
 
''``''``''``''``''``''``''``''``''``''``''``''``''``''``''``''
James Huckaby                  mailto:James.B.Huckaby@LMCo.com
''``''``''``''``''``''``''``''``''``''``''``''``''``''``''``''
``''``''``''``''``''``''``''``''``''``''``''``''``''``''``''``




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

* Re: C++ to Ada Link Problems
  1998-02-27  0:00     ` Robert Dewar
@ 1998-02-28  0:00       ` Larry Kilgallen
  0 siblings, 0 replies; 11+ messages in thread
From: Larry Kilgallen @ 1998-02-28  0:00 UTC (permalink / raw)



In article <dewar.888636612@merv>, dewar@merv.cs.nyu.edu (Robert Dewar) writes:

> There is certainly nothing secret about the message, but I try to be
> aware of an appropriate line between appropriate posts and commercials :-)
> My own feeling is that commercial announcements of new products etc are
> fine for CLA, but one has to be careful about advocacy!

To my mind one of the most effective messages about a product is that there
are ongoing changes to address defects.  (No offense attended; I come from
a school of thought where every little nit which is not exactly the way the
user wants it is a "defect".  Once that terminology issue is settled, there
can be clear effort as to what the resolution shall be and on what schedule.
"Setting user expectations" is the marketing term for one way of addressing
defects.  At the wildest extreme, if someone thought GNAT should be able to
read Delphi projects and convert the code to Ada on the fly, others users
would probably have different priorities -- based in no small part on how
much effort would be expended to the detriment of other efforts.)  When
I read folk fussing about whether version 3.0.11.pqz has reached various
stages of the distribution pipeline, I am encouraged that there is activity
on the distribution pipeline and the results in the past have been
sufficiently worthwhile for people to care about what comes next.

Another category of vendor posts which I find quite helpful is the sort
which describe some little-known capability in response to a query, as it
helps those who do not use the product learn what it can do without having
to get the manual and read it.  (As for GNAT in particular, when the time
comes for me to use it, I do promise to read the manual :-).

Larry Kilgallen




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

* Re: C++ to Ada Link Problems
  1998-02-27  0:00     ` James Huckaby
  1998-02-27  0:00       ` Stanley R. Allen
@ 1998-02-28  0:00       ` Simon Wright
  1 sibling, 0 replies; 11+ messages in thread
From: Simon Wright @ 1998-02-28  0:00 UTC (permalink / raw)



James Huckaby <jhuckaby@mps.lmtas.lmco.com> writes:

> I think I might be able to redirect the a.ld command to
> use CC instead of ld (it will probably be trial and error
> for awhile).  Do you have any examples of munchers
> or munching tools?  I did a Yahoo! search and it was
> very fascinated about the wrong sort of munching and
> the painter Muench. (ue = u umlaut)

Didn't you say you weren't allowed to use commercially unsupported
tools?


You would be *far* better off with GNAT (and, of course, support from
ACT; not cheap, perhaps, but much more so than having your project
fall off the cliff).

-- 
Simon Wright                        Work Email: simon.j.wright@gecm.com
GEC-Marconi Radar & Defence Systems            Voice: +44(0)1705-701778
Command & Information Systems Division           FAX: +44(0)1705-701800




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

end of thread, other threads:[~1998-02-28  0:00 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <9802271359.AA07254@nile.gnat.com>
1998-02-27  0:00 ` C++ to Ada Link Problems James Huckaby
1998-02-27  0:00   ` Robert Dewar
1998-02-27  0:00   ` Stanley R. Allen
1998-02-27  0:00     ` James Huckaby
1998-02-27  0:00       ` Stanley R. Allen
1998-02-28  0:00       ` Simon Wright
1998-02-27  0:00   ` Larry Kilgallen
1998-02-27  0:00     ` Robert Dewar
1998-02-28  0:00       ` Larry Kilgallen
1998-02-25  0:00 James Huckaby
     [not found] ` <9802270246.AA28724@MERV.CS.NYU.EDU>
1998-02-27  0:00   ` James Huckaby

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