• Very basic question: How to use gnatmake (not gprbuild) using external

    From Kenneth Wolcott@21:1/5 to All on Tue Jun 27 16:44:07 2023
    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Jeffrey R.Carter@21:1/5 to Kenneth Wolcott on Wed Jun 28 09:20:05 2023
    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Kenneth Wolcott@21:1/5 to Jeffrey R.Carter on Wed Jun 28 11:25:26 2023
    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Jeffrey R.Carter@21:1/5 to Kenneth Wolcott on Wed Jun 28 21:02:13 2023
    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Kenneth Wolcott@21:1/5 to Jeffrey R.Carter on Wed Jun 28 12:34:23 2023
    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)