comp.lang.ada
 help / color / mirror / Atom feed
* Very basic question: How to use gnatmake (not gprbuild) using external libraries?
@ 2023-06-27 23:44 Kenneth Wolcott
  2023-06-28  7:20 ` Jeffrey R.Carter
  0 siblings, 1 reply; 5+ messages in thread
From: Kenneth Wolcott @ 2023-06-27 23:44 UTC (permalink / raw)


Hi;

  Very basic question here.

  I have downloaded several examples of Ada code from the Rosetta Code web site.  Some very interesting stuff!

  I'm on a Mac with an M1 chip using the gnat 13.1 compiler from Simon Wright...

  I see many of these Rsoetta Code examples refer to external libraries (SDL, XML, GTK, etc).  I have found most under ALIRE.  I have found most of them in GitHub (etc).

  I'm not using ALR much yet because I can't seem to successfully get full crates because I'm using an external gnat compiler (I'm on a Mac with a M1 chip) and it seems to only like crates bundled with the compiler on ALR :-( That is a question for a different post...

  So, my questions are:
  1. Where do I place the SDL library from GitHub?
  2. Do I compile/install the package?
  3. When using gnatmake do I use -I to specify where the library I'm referencing is found?
  4. Once #3 is answered, I assume that I "with package" as if the '*.ad[sb]' files were co-located with my Ada program, is that correct?

Thanks,
Ken Wolcott

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

* Re: Very basic question: How to use gnatmake (not gprbuild) using external libraries?
  2023-06-27 23:44 Very basic question: How to use gnatmake (not gprbuild) using external libraries? Kenneth Wolcott
@ 2023-06-28  7:20 ` Jeffrey R.Carter
  2023-06-28 18:25   ` Kenneth Wolcott
  0 siblings, 1 reply; 5+ messages in thread
From: Jeffrey R.Carter @ 2023-06-28  7:20 UTC (permalink / raw)


On 2023-06-28 01:44, Kenneth Wolcott wrote:
> 
>    1. Where do I place the SDL library from GitHub?

That is up to you. It goes in /path/to/SDL/, where you choose /path/to/.

>    2. Do I compile/install the package?

The library may have specific compilation/installation instructions. Generally 
you should follow those.

>    3. When using gnatmake do I use -I to specify where the library I'm referencing is found?

This depends on the answer to 2. If you have all the source files for the 
library in /path/to/SDL/, and have compiled them so their .ali and .o files are 
also there, then using -I/path/to/SDL/ works fine. This is simple and easy. As 
S/W engineers always try to keep things as simple as possible, this is the 
approach I tend to use.

Coders, on the other hand, like to introduce unnecessary complexity, and you 
will find lots of projects with baroque directory structures, maybe with source 
files in /path/to/SDL/src/, .ali and .o files in /path/to/SDL/lib/, test program 
source files in /path/to/SDL/test/src, their .ali and .o files in 
/path/to/SDL/test/lib/, and executables in /path/to/SDL/test/bin/. Such 
directory structures are gnatmake unfriendly, and the simple -I approach doesn't 
work. You'll have to look into the exact meaning of -I and -a, and maybe others.

>    4. Once #3 is answered, I assume that I "with package" as if the '*.ad[sb]' files were co-located with my Ada program, is that correct?

The Ada language definition is independent of how and where source and 
compilation artifacts are stored, so context clauses are necessarily independent 
of such concepts. In other words, yes. This kind of information is handled by 
the compilation options such as -I.

-- 
Jeff Carter
"He nevere yet no vileynye ne sayde
In al his lyf unto no maner wight."
Canterbury Tales
156

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

* Re: Very basic question: How to use gnatmake (not gprbuild) using external libraries?
  2023-06-28  7:20 ` Jeffrey R.Carter
@ 2023-06-28 18:25   ` Kenneth Wolcott
  2023-06-28 19:02     ` Jeffrey R.Carter
  0 siblings, 1 reply; 5+ messages in thread
From: Kenneth Wolcott @ 2023-06-28 18:25 UTC (permalink / raw)


On Wednesday, June 28, 2023 at 12:20:09 AM UTC-7, Jeffrey R.Carter wrote:
> On 2023-06-28 01:44, Kenneth Wolcott wrote: 
> > 
> > 1. Where do I place the SDL library from GitHub?
> That is up to you. It goes in /path/to/SDL/, where you choose /path/to/.

Cool.

> > 2. Do I compile/install the package?
> The library may have specific compilation/installation instructions. Generally 
> you should follow those.

Ok.

> > 3. When using gnatmake do I use -I to specify where the library I'm referencing is found?
> This depends on the answer to 2. If you have all the source files for the 
> library in /path/to/SDL/, and have compiled them so their .ali and .o files are 
> also there, then using -I/path/to/SDL/ works fine. This is simple and easy. As 
> S/W engineers always try to keep things as simple as possible, this is the 
> approach I tend to use. 

Use "-I/path", but do not use "-L/path"?

> Coders, on the other hand, like to introduce unnecessary complexity, and you 
> will find lots of projects with baroque directory structures, maybe with source 
> files in /path/to/SDL/src/, .ali and .o files in /path/to/SDL/lib/, test program 
> source files in /path/to/SDL/test/src, their .ali and .o files in 
> /path/to/SDL/test/lib/, and executables in /path/to/SDL/test/bin/. Such 
> directory structures are gnatmake unfriendly, and the simple -I approach doesn't 
> work. You'll have to look into the exact meaning of -I and -a, and maybe others.

Yeah, I like to keep things simple as well :-)

I'm not sure I understand the distinction between "-I/path" and "-L/path".  I think when one includes ("-I/path") something it will be compiled along with what I'm trying to compile and when I use "-L/path" it means use *.obj, *.ali, etc at the linking stage.  Is that correct?

> > 4. Once #3 is answered, I assume that I "with package" as if the '*.ad[sb]' files were co-located with my Ada program, is that correct?
> The Ada language definition is independent of how and where source and 
> compilation artifacts are stored, so context clauses are necessarily independent 
> of such concepts. In other words, yes. This kind of information is handled by 
> the compilation options such as -I. 

Thank you for the info!

Now I will make a new post regarding the compilation error I received with the SDL package.

Thanks,
Ken Wolcott

> -- 
> Jeff Carter 
> "He nevere yet no vileynye ne sayde 
> In al his lyf unto no maner wight." 
> Canterbury Tales 
> 156

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

* Re: Very basic question: How to use gnatmake (not gprbuild) using external libraries?
  2023-06-28 18:25   ` Kenneth Wolcott
@ 2023-06-28 19:02     ` Jeffrey R.Carter
  2023-06-28 19:34       ` Kenneth Wolcott
  0 siblings, 1 reply; 5+ messages in thread
From: Jeffrey R.Carter @ 2023-06-28 19:02 UTC (permalink / raw)


On 2023-06-28 20:25, Kenneth Wolcott wrote:
> On Wednesday, June 28, 2023 at 12:20:09 AM UTC-7, Jeffrey R.Carter wrote:
>> On 2023-06-28 01:44, Kenneth Wolcott wrote:
>>>
>>> 1. Where do I place the SDL library from GitHub?
>> That is up to you. It goes in /path/to/SDL/, where you choose /path/to/.
> 
> Cool.

I probably should have mentioned that the library build procedure may expect a 
specific directory structure under /path/to/SDL/, and failure to create/keep 
that may result in the build process failing.

> I'm not sure I understand the distinction between "-I/path" and "-L/path".  I think when one includes ("-I/path") something it will be compiled along with what I'm trying to compile and when I use "-L/path" it means use *.obj, *.ali, etc at the linking stage.  Is that correct?

 From the GNAT user guide 
(https://docs.adacore.com/live/wave/gnat_ugn/html/gnat_ugn/gnat_ugn/building_executable_programs_with_gnat.html#switches-for-gnatmake), 
-I/path/ is equivalent to -aO/path/ -aI/path/. -aO/path/ says to look for 
library and object files (.ali & .o) in /path/ in addition to the current 
directory. -aI/path/ says to look for source files in /path/ in addition to the 
current directory.

-L/path/ is equivalent to -largs -L/path/, so it's a linker switch.

I should probably have mentioned that it's probably a good idea to write-protect 
the library's .ali files one the library is built. This prevents other 
compilations from recompiling the library.

In my experience, if you have the library's source, .ali, and .o files in 
/path/, then -I/path/ is all you need to compile and link against the library.

-- 
Jeff Carter
"He nevere yet no vileynye ne sayde
In al his lyf unto no maner wight."
Canterbury Tales
156

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

* Re: Very basic question: How to use gnatmake (not gprbuild) using external libraries?
  2023-06-28 19:02     ` Jeffrey R.Carter
@ 2023-06-28 19:34       ` Kenneth Wolcott
  0 siblings, 0 replies; 5+ messages in thread
From: Kenneth Wolcott @ 2023-06-28 19:34 UTC (permalink / raw)


On Wednesday, June 28, 2023 at 12:02:16 PM UTC-7, Jeffrey R.Carter wrote:
> On 2023-06-28 20:25, Kenneth Wolcott wrote: 
> > On Wednesday, June 28, 2023 at 12:20:09 AM UTC-7, Jeffrey R.Carter wrote: 
> >> On 2023-06-28 01:44, Kenneth Wolcott wrote: 
> >>> 
> >>> 1. Where do I place the SDL library from GitHub? 
> >> That is up to you. It goes in /path/to/SDL/, where you choose /path/to/. 
> > 
> > Cool.
> I probably should have mentioned that the library build procedure may expect a 
> specific directory structure under /path/to/SDL/, and failure to create/keep 
> that may result in the build process failing.
> > I'm not sure I understand the distinction between "-I/path" and "-L/path". I think when one includes ("-I/path") something it will be compiled along with what I'm trying to compile and when I use "-L/path" it means use *.obj, *.ali, etc at the linking stage. Is that correct?
> From the GNAT user guide 
> (https://docs.adacore.com/live/wave/gnat_ugn/html/gnat_ugn/gnat_ugn/building_executable_programs_with_gnat.html#switches-for-gnatmake), 
> -I/path/ is equivalent to -aO/path/ -aI/path/. -aO/path/ says to look for 
> library and object files (.ali & .o) in /path/ in addition to the current 
> directory. -aI/path/ says to look for source files in /path/ in addition to the 
> current directory. 
> 
> -L/path/ is equivalent to -largs -L/path/, so it's a linker switch. 
> 
> I should probably have mentioned that it's probably a good idea to write-protect 
> the library's .ali files one the library is built. This prevents other 
> compilations from recompiling the library. 
> 
> In my experience, if you have the library's source, .ali, and .o files in 
> /path/, then -I/path/ is all you need to compile and link against the library.

Thank you for the clarification/elaboration.

Ken

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

end of thread, other threads:[~2023-06-28 19:34 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-27 23:44 Very basic question: How to use gnatmake (not gprbuild) using external libraries? Kenneth Wolcott
2023-06-28  7:20 ` Jeffrey R.Carter
2023-06-28 18:25   ` Kenneth Wolcott
2023-06-28 19:02     ` Jeffrey R.Carter
2023-06-28 19:34       ` Kenneth Wolcott

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