comp.lang.ada
 help / color / mirror / Atom feed
* GNAT for NT Linking Problem
@ 1996-09-09  0:00 Matt O'Hara
  1996-09-09  0:00 ` Tom Griest
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Matt O'Hara @ 1996-09-09  0:00 UTC (permalink / raw)



Gentlepeople -

I'm in the process of porting a Solaris Ada program to the PC, using
GNAT 304a for Windows NT (freshly ftp'd and installed). This Ada program
uses the C libraries extensively (basic things, like fputc, fgetc, feof,
toupper, etc).

All the Ada code compiles correctly, yet when I try to link I am getting
errors referencing some of these C libraries. For example, it cant find
things like toupper or feof, yet it (evidently, based on the lack of
error message) can find things like tolower and fputc. Considering that
these routines should come from the same sets of libraries, it seems odd
that the linker could find one thing but not the others.

I had similar problems when I tried installing and using the GNAT 301a
compiler.

Any ideas?

-- 
Matthew H. O'Hara
Principal S/W Engineer
Lockheed Martin Tactical Defense Systems, Eagan, MN
612-456-3228               matthew.h.ohara@lmco.com




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

* Re: GNAT for NT Linking Problem
  1996-09-09  0:00 GNAT for NT Linking Problem Matt O'Hara
  1996-09-09  0:00 ` Tom Griest
@ 1996-09-09  0:00 ` Jonas Nygren
  1996-09-09  0:00   ` Michael Feldman
  1996-09-10  0:00 ` Bruce.Conroy
  2 siblings, 1 reply; 9+ messages in thread
From: Jonas Nygren @ 1996-09-09  0:00 UTC (permalink / raw)



Matt O'Hara wrote:
> 
> Gentlepeople -
> 
> I'm in the process of porting a Solaris Ada program to the PC, using
> GNAT 304a for Windows NT (freshly ftp'd and installed). This Ada program
> uses the C libraries extensively (basic things, like fputc, fgetc, feof,
> toupper, etc).
> 
> All the Ada code compiles correctly, yet when I try to link I am getting
> errors referencing some of these C libraries. For example, it cant find
> things like toupper or feof, yet it (evidently, based on the lack of
> error message) can find things like tolower and fputc. Considering that
> these routines should come from the same sets of libraries, it seems odd
> that the linker could find one thing but not the others.
> 
> I had similar problems when I tried installing and using the GNAT 301a
> compiler.
> 
> Any ideas?

Gnat uses some of the stdio routines to implement Ada file-io. 
Look in the 'adaincludes' directory for i-cstrea.ads
and you find what is available via Gnat. If you need more you would
have to include these interfaces yourself via some library or .obj
file.

> 
> --
> Matthew H. O'Hara
> Principal S/W Engineer
> Lockheed Martin Tactical Defense Systems, Eagan, MN
> 612-456-3228               matthew.h.ohara@lmco.com




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

* Re: GNAT for NT Linking Problem
  1996-09-09  0:00 GNAT for NT Linking Problem Matt O'Hara
@ 1996-09-09  0:00 ` Tom Griest
  1996-09-09  0:00 ` Jonas Nygren
  1996-09-10  0:00 ` Bruce.Conroy
  2 siblings, 0 replies; 9+ messages in thread
From: Tom Griest @ 1996-09-09  0:00 UTC (permalink / raw)



Matt O'Hara <mohara@planet8.eag.unisysgsg.com> writes:

[snip]

>All the Ada code compiles correctly, yet when I try to link I am getting
>errors referencing some of these C libraries. For example, it cant find
>things like toupper or feof, yet it (evidently, based on the lack of
>error message) can find things like tolower and fputc.

Only functions actually required by the Ada compiler and standard
Ada libraries are part of the libada libraries.  Hopefully, a version
of the Cygnus libc will be available for the next release on the
win32 platforms, and this should solve your problem.  Or, you
could try using the Ada equivalent libraries instead of the
"C" library,   like:    Ada.Characters.Handling.To_Upper.  :-)

-Tom




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

* Re: GNAT for NT Linking Problem
  1996-09-09  0:00 ` Jonas Nygren
@ 1996-09-09  0:00   ` Michael Feldman
  1996-09-23  0:00     ` Klaus Wyss
  0 siblings, 1 reply; 9+ messages in thread
From: Michael Feldman @ 1996-09-09  0:00 UTC (permalink / raw)



In article <3234724E.251E@joy.ericsson.se>,
Jonas Nygren  <jonas@joy.ericsson.se> wrote:
>Matt O'Hara wrote:

>> I'm in the process of porting a Solaris Ada program to the PC, using
>> GNAT 304a for Windows NT (freshly ftp'd and installed). This Ada program
>> uses the C libraries extensively (basic things, like fputc, fgetc, feof,
>> toupper, etc).

Since you are porting to GNAT, why not take the opportunity to
Ada 95-ize your program and get away from using those C libraries.
For example, toupper, etc., are part of the Ada 95 standard libs,
in this case Ada.Characters.Handling.

And why use the C IO routines? Is there a problem with Ada.Text_IO?

>Gnat uses some of the stdio routines to implement Ada file-io. 
>Look in the 'adaincludes' directory for i-cstrea.ads
>and you find what is available via Gnat. If you need more you would
>have to include these interfaces yourself via some library or .obj
>file.

All this is true, but maybe you should have a look at your code to
see if you can make use of Ada 95 stuff that will free you from
(most of) the C lib facilities.

The only thing I can think of that would require the C libs is if
(possibly) those f* routines are unbuffered. Do you need unbuffered 
input/output?

Mike Feldman
------------------------------------------------------------------------
Michael B. Feldman -  chair, SIGAda Education Working Group
Professor, Dept. of Electrical Engineering and Computer Science
The George Washington University -  Washington, DC 20052 USA
202-994-5919 (voice) - 202-994-0227 (fax) 
http://www.seas.gwu.edu/faculty/mfeldman
------------------------------------------------------------------------
       Pork is all that money the government gives the other guys.
------------------------------------------------------------------------
WWW: http://lglwww.epfl.ch/Ada/ or http://info.acm.org/sigada/education
------------------------------------------------------------------------




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

* Re: GNAT for NT Linking Problem
  1996-09-09  0:00 GNAT for NT Linking Problem Matt O'Hara
  1996-09-09  0:00 ` Tom Griest
  1996-09-09  0:00 ` Jonas Nygren
@ 1996-09-10  0:00 ` Bruce.Conroy
  2 siblings, 0 replies; 9+ messages in thread
From: Bruce.Conroy @ 1996-09-10  0:00 UTC (permalink / raw)



In <32342D50.1E1C@planet8.eag.unisysgsg.com>, Matt O'Hara
<mohara@planet8.eag.unisysgsg.com> writes:

>I'm in the process of porting a Solaris Ada program to the PC, using
>GNAT 304a for Windows NT (freshly ftp'd and installed). This Ada program
>uses the C libraries extensively (basic things, like fputc, fgetc, feof,
>toupper, etc).
>
>All the Ada code compiles correctly, yet when I try to link I am getting
>errors referencing some of these C libraries. For example, it cant find
>things like toupper or feof, yet it (evidently, based on the lack of
>error message) can find things like tolower and fputc. Considering that
>these routines should come from the same sets of libraries, it seems odd
>that the linker could find one thing but not the others.
>
>I had similar problems when I tried installing and using the GNAT 301a
>compiler.
>
>Any ideas?


The ones you can't find are the ones that are defined as macros in one
of the C header files rather than real code. Thus there is nothing in
the library to link in. It is very system dependent. The one I have
fought is "feof" which is a macro on OS/2, but compiled code on
Solaris.

my solution is shown in the following body definition:

   function FEOF(HANDLE : HANDLE_TYPE) return integer;
   pragma Import (C, FEOF
      -- on some systems FEOF is a
      -- macro. On these it is necessary
      -- to compile the following program
         --  #include <stdio.h>
         --
         --  int END_FILE (FILE *s)
         --     {return (s->flags & _IOEOF ? 1: 0);}
      -- then add the resuling object to either
      -- the linker or one of the libraries,
      -- and uncomment the following line
              , "END_FILE"
           );

Lots of luck.

     Bruce







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

* Re: GNAT for NT Linking Problem
  1996-09-09  0:00   ` Michael Feldman
@ 1996-09-23  0:00     ` Klaus Wyss
  1996-09-23  0:00       ` Tom Griest
                         ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Klaus Wyss @ 1996-09-23  0:00 UTC (permalink / raw)



Michael Feldman wrote:
 
> Since you are porting to GNAT, why not take the opportunity to
> Ada 95-ize your program and get away from using those C libraries.
> For example, toupper, etc., are part of the Ada 95 standard libs,
> in this case Ada.Characters.Handling.
> 
> And why use the C IO routines? Is there a problem with Ada.Text_IO?
> 
> >Gnat uses some of the stdio routines to implement Ada file-io.
> >Look in the 'adaincludes' directory for i-cstrea.ads
> >and you find what is available via Gnat. If you need more you would
> >have to include these interfaces yourself via some library or .obj
> >file.
> 
> All this is true, but maybe you should have a look at your code to
> see if you can make use of Ada 95 stuff that will free you from
> (most of) the C lib facilities.
> 
> The only thing I can think of that would require the C libs is if
> (possibly) those f* routines are unbuffered. Do you need unbuffered
> input/output?
> 
> Mike Feldman


                                                                     
That's a typical sugestion of somebody living in the pure clean Ada
world
But the real world is not clean. It has dirty things like Windows,OLE
3rd party libraries .....
                                                                    
It would be crazy the reimplent all that stuff (maybe people in the
military aerea can do that)
                                                          
So what we need is a quick way to access all this C stuff from Ada.
A standard way to take C or C++ headers and make the this modules
acessible in Ada. 
                                                                
If we don't be able to access all this C,C++ things in a elegant simple
way, more and more applications will change from Ada to C/C++. 
The greater productivity of Ada programming doesn't help me if i lose
the time in solving the interface problems to other libraries.

Klaus Wyss
Union Bank of Switzerland




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

* Re: GNAT for NT Linking Problem
  1996-09-23  0:00     ` Klaus Wyss
@ 1996-09-23  0:00       ` Tom Griest
  1996-09-24  0:00       ` Robert Dewar
  1996-09-25  0:00       ` Matt O'Hara
  2 siblings, 0 replies; 9+ messages in thread
From: Tom Griest @ 1996-09-23  0:00 UTC (permalink / raw)



In article <3246AB3C.4A17@ubs.com> klaus.wyss@ubs.com writes:

[stuff snipped about using Ada functions rather than C counterparts snipped]

>That's a typical sugestion of somebody living in the pure clean Ada
>world
>But the real world is not clean. It has dirty things like Windows,OLE
>3rd party libraries .....
>                                                                    
>It would be crazy the reimplent all that stuff (maybe people in the
>military aerea can do that)

Here is an example where the answer depends on your situation.  If
you have a bunch of OLE libraries, etc. there is no problem linking
with them.  Currently you just have to supply the 3rd party (ie. MS)
C library.  The response was intended for folks trying to "get by"
with just the free GNAT package.  Until all of the Cygnus libraries are
integrated with GNAT, you'll have to link with your own LIBC.

>So what we need is a quick way to access all this C stuff from Ada.
>A standard way to take C or C++ headers and make the this modules
>acessible in Ada. 

This is available:  Cbind does this.

>If we don't be able to access all this C,C++ things in a elegant simple
>way, more and more applications will change from Ada to C/C++. 

True.

>The greater productivity of Ada programming doesn't help me if i lose
>the time in solving the interface problems to other libraries.

Agreed.

-Tom




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

* Re: GNAT for NT Linking Problem
  1996-09-23  0:00     ` Klaus Wyss
  1996-09-23  0:00       ` Tom Griest
@ 1996-09-24  0:00       ` Robert Dewar
  1996-09-25  0:00       ` Matt O'Hara
  2 siblings, 0 replies; 9+ messages in thread
From: Robert Dewar @ 1996-09-24  0:00 UTC (permalink / raw)



Klaus wrote:

"It would be crazy the reimplent all that stuff (maybe people in the
military aerea can do that)

So what we need is a quick way to access all this C stuff from Ada.
A standard way to take C or C++ headers and make the this modules
acessible in Ada.

If we don't be able to access all this C,C++ things in a elegant simple
way, more and more applications will change from Ada to C/C++.
The greater productivity of Ada programming doesn't help me if i lose
the time in solving the interface problems to other libraries.

Klaus Wyss
Union Bank of Switzerland"



Well I guess you have not looked much at Ada 95 yet, but in fact everyone
agrees with this in general, and moreover, it is certainly possible to do
this kind of interfacing, and a lot of work has been put in both in the
Ada 95 definition, and in GNAT to make this easi3er, but if this kind of
interfacing is what you need, all the more reason to switch to Ada 95!

Second, for simple operations like To_Upper, you will indeed be better
off using the Ada 95 equivalents because (a) you will often find that
the Unix versions do not handle Latin-1 properly (in Switzerland, this
is presumably of interest) and (b) these can be macros in Unix, which
of course there is no easy way to interface directly to, since they are
C macros.

For Text_IO, it is a toss up, the trouble with the C routines is that they
are weakly typed, and can easily overrwite buffers etc. All this is checked
in Ada, so in the long run, you may save yourselves a lot of boring
debugging by using the safer Ada versions.

But of course for big things, everyone agrees, no one is going to 
reimplement the whole C world in Ada, and such an attempt would be silly
even *if* the resources existed to do it, which they do not!





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

* Re: GNAT for NT Linking Problem
  1996-09-23  0:00     ` Klaus Wyss
  1996-09-23  0:00       ` Tom Griest
  1996-09-24  0:00       ` Robert Dewar
@ 1996-09-25  0:00       ` Matt O'Hara
  2 siblings, 0 replies; 9+ messages in thread
From: Matt O'Hara @ 1996-09-25  0:00 UTC (permalink / raw)



> 
> Michael Feldman wrote:
>

Michael -

Sorry; I started this topic and then got pulled away from it.
 
> > Since you are porting to GNAT, why not take the opportunity to
> > Ada 95-ize your program and get away from using those C libraries.
> > For example, toupper, etc., are part of the Ada 95 standard libs,
> > in this case Ada.Characters.Handling.
> >

I have started to do this, although I have discovered a limitation with
Ada95 that I did not care for. See the next response...

> > And why use the C IO routines? Is there a problem with Ada.Text_IO?
> >
> > The only thing I can think of that would require the C libs is if
> > (possibly) those f* routines are unbuffered. Do you need unbuffered
> > input/output?
> >

We used the C IO routines because Ada 83 Text IO (which the original
code was based on) could not handle Japanese (Wide) characters, and we
needed to Internationalize our program. Since we were Solaris based, and
Solaris has all these nice, neat Wide libraries, we simply built our own
text_io replacement package which used our own wide_character types, and
interfaced to the Solaris C wide libraries.

Ada 95 does have wide_character functions, including I/O. Although I am
still playing around with converting this to Ada95, I have noticed that
its Wide_Io does not handle wide_character file/path names; they are
String only. This seems like an unnecessary restriction; the wide_io
package we developed allowed wide_character file names. Why should Ada
95 force non-English developers to use only English names?

> > Mike Feldman
> 
> 

-- 
Matthew H. O'Hara
Principal S/W Engineer
Lockheed Martin Tactical Defense Systems, Eagan, MN
612-456-3228               matthew.h.ohara@lmco.com




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

end of thread, other threads:[~1996-09-25  0:00 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-09-09  0:00 GNAT for NT Linking Problem Matt O'Hara
1996-09-09  0:00 ` Tom Griest
1996-09-09  0:00 ` Jonas Nygren
1996-09-09  0:00   ` Michael Feldman
1996-09-23  0:00     ` Klaus Wyss
1996-09-23  0:00       ` Tom Griest
1996-09-24  0:00       ` Robert Dewar
1996-09-25  0:00       ` Matt O'Hara
1996-09-10  0:00 ` Bruce.Conroy

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