comp.lang.ada
 help / color / mirror / Atom feed
* Linking confusion
@ 2004-09-03  9:08 Andrew Carroll
  2004-09-06  0:12 ` Brian May
  2004-09-06  3:46 ` Pylinius
  0 siblings, 2 replies; 4+ messages in thread
From: Andrew Carroll @ 2004-09-03  9:08 UTC (permalink / raw)
  To: comp.lang.ada

Okay, I recently downloaded AdaSDL sources for a project I am starting
and tried to "make" the sources.  (In case you are wondering, AdaBind
has taken the back burner for now.  Anyway...)

There is a file that comes with the sources called compile.adb.  Here is
the whole file:
pragma Warnings (off);

with gl_h;
with glu_h;
with AdaGL;

procedure compile is
begin
   null;
end compile;


When I tried to make the AdaSDL sources (compile.adb) I stumbled onto a
linking error that said it could not find the libraries specified with
the "-l" option.  It said it could not find one two of the libraries for
GL and GLU.  So, I edited the make.conf file so that it could find the
appropriate libraries (GL and GLU libraries, which are actually Mesa
libraries on FreeBSD).  I then started the make process over again and
came up with a second error.  Here is the output:

-bash-2.05b$ make
make -C GL
gnatmake -O3 -I../binding -I../GL -I/usr/X11R6/include/GL
 compile -largs -L/usr/lib -L/usr/local/lib -L~/lib -L/usr/X11R6/lib
gnatbind -aO./ -aO../binding -aO../GL -aO/usr/X11R6/include/GL -I- -x
compile.ali
gnatlink -L/usr/lib -L/usr/local/lib -L~/lib -L/usr/X11R6/lib
compile.ali
/usr/local/lib/gcc-lib/i386-unknown-freebsd5.1/2.8.1/adalib//libgnat.so:
warning: mktemp() possibly used unsafely; consider using mkstemp()
./adagl.o: In function `adagl__glgetstring':
./adagl.o(.text+0xb): undefined reference to `glGetString'
./adagl.o(.text+0x1a): undefined reference to `glGetString'
gnatlink: cannot call /usr/local/bin/adagcc
gnatmake: *** link failed.


So I investigated a little further and now have some questions.  The
first question is related to gnatlink.  If I specify "-L/usr/X11R6/lib"
then it should search all the libraries in that directory for the
library(s) that apply correct?  In this case I think it is libGL.a or
libGL.so (and libGLU.a or libGLU.so).  Those libraries are in the
/usr/X11R6/lib directory and "glGetString" implementation is provided in
those libraries.  gl_h.ads and glu_h.ads define the binding to GL for
AdaGL and they use Interfaces.C.  Now in order for gnatlink to find the
"Interface implementations" that gl_h.ads and glu_h.ads define, the
libraries for GL and GLU must be provided to gnatlink.  Right?

So, now, on to other questions.  I pasted the contents of adagl.adb
below.  At first I thought that the glGetString in the AdaGL package
below was the only glGetString.  Then I looked in the gl_h.ads file and
found a declaration for a second glGetString.  Now even if the linking
problem were fixed, wouldn't there be a compiler error as to which
glGetString function to use in the Get_chars_ptr function?  (because
there is no package prefix on the function call).  I thought Ada was not
"context sensitive" as in return value making up part of function
signature?  Anyway, no biggie on the function signature question.  Once
I get it to link I'll be able to tell.

package body AdaGL is

   package CS  renames Interfaces.C.Strings;

   function To_chars_ptr is new Ada.Unchecked_Conversion (
      GLubyte_Ptr, CS.chars_ptr);

   --  ======================================
   function Get_chars_ptr (Chars_Ref : GLenum) return CS.chars_ptr is
   begin
      return To_chars_ptr (glGetString (Chars_Ref));
   end Get_chars_ptr;

   --  ======================================
   function glGetString (Chars_Ref : GLenum) return String is
      temp_chars_ptr : CS.chars_ptr;
   begin
      temp_chars_ptr := Get_chars_ptr (Chars_ref);
      if temp_chars_ptr /= Cs.Null_Ptr then
         return CS.Value (Get_chars_ptr (Chars_Ref));
      else
         return "";
      end if;
   end glGetString;

   --  ======================================
end AdaGL;


P.S.
I had to reinstall email client.  How's the word wrap?

Andrew Carroll
Carroll-Tech
720-273-6814
andrew@carroll-tech.net




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

* Re: Linking confusion
  2004-09-03  9:08 Linking confusion Andrew Carroll
@ 2004-09-06  0:12 ` Brian May
  2004-09-06  3:46 ` Pylinius
  1 sibling, 0 replies; 4+ messages in thread
From: Brian May @ 2004-09-06  0:12 UTC (permalink / raw)


>>>>> "Andrew" == Andrew Carroll <andrew@carroll-tech.net> writes:

    Andrew> warning: mktemp() possibly used unsafely; consider using mkstemp()
    Andrew> ./adagl.o: In function `adagl__glgetstring':
    Andrew> ./adagl.o(.text+0xb): undefined reference to `glGetString'
    Andrew> ./adagl.o(.text+0x1a): undefined reference to `glGetString'
    Andrew> gnatlink: cannot call /usr/local/bin/adagcc
    Andrew> gnatmake: *** link failed.

I have to wonder why the adagl__glgetstring function (which presumably
means the glGetString function in the adagl function) is trying to
reference a glGetString function (which looks like it could be a
imported C function, but there is no evidence of that in the source
file).

Are you sure that the ./adagl.o file corresponds with the source file
excerpt you showed?

Anyway, if I didn't know better, I would suggest that your ADA GL
library binds to the C GL library, but you haven't linked in the GL C
library (libGL on Linux).
-- 
Brian May <bam@snoopy.apana.org.au>



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

* Re: Linking confusion
  2004-09-03  9:08 Linking confusion Andrew Carroll
  2004-09-06  0:12 ` Brian May
@ 2004-09-06  3:46 ` Pylinius
  1 sibling, 0 replies; 4+ messages in thread
From: Pylinius @ 2004-09-06  3:46 UTC (permalink / raw)


Andrew Carroll wrote:
> Okay, I recently downloaded AdaSDL sources for a project I am starting
> and tried to "make" the sources.  (In case you are wondering, AdaBind
> has taken the back burner for now.  Anyway...)
> 
I would try using GPS and project file syntax. I can take extremely
complicated make/build configurations and reduce it quickly to
something debuggable.




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

* Linking confusion
@ 2004-09-06  8:54 Andrew Carroll
  0 siblings, 0 replies; 4+ messages in thread
From: Andrew Carroll @ 2004-09-06  8:54 UTC (permalink / raw)
  To: comp.lang.ada

Eh, disregard...
Eh, brainfart..

-L/usr/X11R6/lib needs to be paired with -lGL -lGLU

eh-hem, so how's the weather?

Andrew Carroll
Carroll-Tech
720-273-6814
andrew@carroll-tech.net




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

end of thread, other threads:[~2004-09-06  8:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-09-03  9:08 Linking confusion Andrew Carroll
2004-09-06  0:12 ` Brian May
2004-09-06  3:46 ` Pylinius
  -- strict thread matches above, loose matches on Subject: below --
2004-09-06  8:54 Andrew Carroll

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