Linking problem sdlada

I’m trying to do the Archimedean spiral
to get sdlada working on my rocky 8 linux box.
It compiles well, but does not link. And I don’t see why.
Here’s the longish output from the link part.
I find it odd that it cannot find the SDL functions.

I started with adding
-L/usr/lib64 -lSDL2 -lSDL2_mixer -lSDL2_ttf -lSDL2_image
which then became
-L/usr/lib64 -lSDL2
-L/usr/lib64 -lSDL2_mixer
-L/usr/lib64 -lSDL2_ttf
-L/usr/lib64 -lSDL2_image

and then I added the gfx and mixer libs

[sattmate@rocky moving_sdl]$ gprbuild -v -j0 -p -XUse_Database=1 -P moving_sdl.gpr "archimedean_spiral"
Changing to object directory of "Moving_sdl": "/usr2/wcs/kgk/target/adalib/global_gpr/moving_sdl/"
/usr2/wcs/tools/gnat/25.0w/libexec/gprbuild/gprbind archimedean_spiral.bexch
/usr2/wcs/tools/gnat/25.0w/bin/gnatbind -o b__archimedean_spiral.adb 
  /usr2/wcs/kgk/target/adalib/global_gpr/moving_sdl/archimedean_spiral.ali
  -E -x -F=/tmp/GPR.5316/GNAT-TEMP-000003.TMP -O=/tmp/GPR.5331/GNAT-TEMP-000001.TMP
  
/usr2/wcs/tools/gnat/25.0w/bin/gcc -c -x ada -gnatA -c -gnatA -gnatWb 
  -gnatiw -gnatws -Os -g -funwind-tables -fstack-check=specific 
  -mtune=generic -march=x86-64 b__archimedean_spiral.adb -o b__archimedean_spiral.o
  
/usr2/wcs/tools/gnat/25.0w/bin/gcc archimedean_spiral.o b__archimedean_spiral.o 
  /usr2/wcs/tools/sdlada2/25.0w/lib/sdlada.release/libsdlada.a 
  /usr2/wcs/tools/gnat/25.0w/lib/aws.static/libaws.a 
  /usr2/wcs/tools/gnat/25.0w/lib/gnatcoll_projects.static/libgnatcoll_projects.a 
  /usr2/wcs/tools/gnat/25.0w/lib/gpr/static/gpr/libgpr.a 
  /usr2/wcs/tools/gnat/25.0w/lib/xmlada/xmlada_schema.static/libxmlada_schema.a 
  /usr2/wcs/tools/gnat/25.0w/lib/xmlada/xmlada_dom.static/libxmlada_dom.a 
  /usr2/wcs/tools/gnat/25.0w/lib/xmlada/xmlada_sax.static/libxmlada_sax.a 
  /usr2/wcs/tools/gnat/25.0w/lib/xmlada/xmlada_input.static/libxmlada_input_sources.a 
  /usr2/wcs/tools/gnat/25.0w/lib/xmlada/xmlada_unicode.static/libxmlada_unicode.a 
  /usr2/wcs/tools/gnat/25.0w/lib/gnatcoll_core.static/libgnatcoll_core.a 
  /usr2/wcs/tools/gnat/25.0w/lib/gnatcoll_minimal.static/libgnatcoll_minimal.a 
  -L/usr2/wcs/kgk/target/global -lsattmate -lodbc /usr2/wcs/tools/sdlada2/25.0w/lib/sdlada.release/libsdlada.a 
  -L/usr/lib64 -lSDL2 
  -L/usr/lib64 -lSDL2_mixer 
  -L/usr/lib64 -lSDL2_ttf 
  -L/usr/lib64 -lSDL2_image 
  -L/usr/lib64 -lSDL2_gfx 
  -L/usr/lib64 -lSDL2_net 
  -ldl 
  -L/usr2/wcs/kgk/target/adalib/global_gpr/moving_sdl/ 
  -L/usr2/wcs/kgk/target/adalib/global_gpr/moving_sdl/ 
  -L/usr2/wcs/kgk/target/adalib/global_gpr/ 
  -L/usr2/wcs/tools/gnat/25.0w/lib/aws.static/ 
  -L/usr2/wcs/tools/gnat/25.0w/lib/gnatcoll_core.static/ 
  -L/usr2/wcs/tools/gnat/25.0w/lib/gnatcoll_minimal.static/ 
  -L/usr2/wcs/tools/gnat/25.0w/lib/gnatcoll_projects.static/ 
  -L/usr2/wcs/tools/gnat/25.0w/lib/gpr/static/gpr/ 
  -L/usr2/wcs/tools/gnat/25.0w/lib/xmlada/xmlada_dom.static/ 
  -L/usr2/wcs/tools/gnat/25.0w/lib/xmlada/xmlada_unicode.static/ 
  -L/usr2/wcs/tools/gnat/25.0w/lib/xmlada/xmlada_sax.static/ 
  -L/usr2/wcs/tools/gnat/25.0w/lib/xmlada/xmlada_input.static/ 
  -L/usr2/wcs/tools/gnat/25.0w/lib/xmlada/xmlada_schema.static/ 
  -L/usr2/wcs/tools/sdlada2/25.0w/lib/sdlada.release/ 
  -L/usr2/wcs/kgk/target/adalib/global_gpr/moving/ 
  -L/usr2/wcs/tools/gnat/25.0w/lib/gcc/x86_64-pc-linux-gnu/13.3.1/adalib/ 
  -static-libgcc -lSDL2 
  /usr2/wcs/tools/gnat/25.0w/lib/gcc/x86_64-pc-linux-gnu/13.3.1/adalib/libgnarl.a 
  /usr2/wcs/tools/gnat/25.0w/lib/gcc/x86_64-pc-linux-gnu/13.3.1/adalib/libgnat.a -lrt 
  -lpthread -lm -ldl -Wl,-rpath-link,/usr2/wcs/tools/gnat/25.0w/lib/gcc/x86_64-pc-linux-gnu/13.3.1//adalib 
  -Wl,-z,origin,-rpath,
   $ORIGIN/..//global:/usr/lib64:
   $ORIGIN/..//adalib/global_gpr/moving_sdl:
   $ORIGIN/..//adalib/global_gpr:
   $ORIGIN/../../..//tools/gnat/25.0w/lib/aws.static:
   $ORIGIN/../../..//tools/gnat/25.0w/lib/gnatcoll_core.static:
   $ORIGIN/../../..//tools/gnat/25.0w/lib/gnatcoll_minimal.static:
   $ORIGIN/../../..//tools/gnat/25.0w/lib/gnatcoll_projects.static:
   $ORIGIN/../../..//tools/gnat/25.0w/lib/gpr/static/gpr:
   $ORIGIN/../../..//tools/gnat/25.0w/lib/xmlada/xmlada_dom.static:
   $ORIGIN/../../..//tools/gnat/25.0w/lib/xmlada/xmlada_unicode.static:
   $ORIGIN/../../..//tools/gnat/25.0w/lib/xmlada/xmlada_sax.static:
   $ORIGIN/../../..//tools/gnat/25.0w/lib/xmlada/xmlada_input.static:
   $ORIGIN/../../..//tools/gnat/25.0w/lib/xmlada/xmlada_schema.static:
   $ORIGIN/../../..//tools/sdlada2/25.0w/lib/sdlada.release:
   $ORIGIN/..//adalib/global_gpr/moving:
   $ORIGIN/../../..//tools/gnat/25.0w/lib/gcc/x86_64-pc-linux-gnu/13.3.1/adalib 
   -o /usr2/wcs/kgk/target/moving_sdl//archimedean_spiral

/usr2/wcs/tools/gnat/25.0w/bin/../lib/gcc/x86_64-pc-linux-gnu/13.3.1/../../../../x86_64-pc-linux-gnu/bin/ld: 
  /usr2/wcs/tools/sdlada2/25.0w/lib/sdlada.release/libsdlada.a(sdl-video-rectangles.o): 
  in function `sdl__video__rectangles__has_intersected__2':
  sdl-video-rectangles.adb:(.text.sdl__video__rectangles__has_intersected__2+0x24):
  undefined reference to `SDL_HasIntersectionF'

/usr2/wcs/tools/gnat/25.0w/bin/../lib/gcc/x86_64-pc-linux-gnu/13.3.1/../../../../x86_64-pc-linux-gnu/bin/ld: 
  /usr2/wcs/tools/sdlada2/25.0w/lib/sdlada.release/libsdlada.a(sdl-video-rectangles.o): 
  in function `sdl__video__rectangles__intersects__3':
  sdl-video-rectangles.adb:(.text.sdl__video__rectangles__intersects__3+0x2d): 
  undefined reference to `SDL_IntersectFRect'

/usr2/wcs/tools/gnat/25.0w/bin/../lib/gcc/x86_64-pc-linux-gnu/13.3.1/../../../../x86_64-pc-linux-gnu/bin/ld: 
  /usr2/wcs/tools/sdlada2/25.0w/lib/sdlada.release/libsdlada.a(sdl-video-rectangles.o): 
  in function `sdl__video__rectangles__union__2':
  sdl-video-rectangles.adb:(.text.sdl__video__rectangles__union__2+0x29): 
  undefined reference to `SDL_UnionFRect'

I then added the static libs

[sattmate@rocky moving_sdl]$ sudo dnf list SDL2*
Repository packages-microsoft-com-prod is listed more than once in the configuration
Last metadata expiration check: 19:38:38 ago on Wed 22 Jan 2025 02:44:28 PM CET.
Installed Packages
SDL2.x86_64                                               2.0.10-2.el8                                    @powertools
SDL2-devel.x86_64                                         2.0.10-2.el8                                    @powertools
SDL2-static.x86_64                                        2.0.10-2.el8                                    @powertools
SDL2_gfx.x86_64                                           1.0.4-10.el8                                    @epel      
SDL2_gfx-devel.x86_64                                     1.0.4-10.el8                                    @epel      
SDL2_image.x86_64                                         2.6.3-1.el8                                     @epel      
SDL2_image-devel.x86_64                                   2.6.3-1.el8                                     @epel      
SDL2_mixer.x86_64                                         2.6.3-1.el8                                     @epel      
SDL2_mixer-devel.x86_64                                   2.6.3-1.el8                                     @epel      
SDL2_net.x86_64                                           2.0.1-15.el8                                    @epel      
SDL2_net-devel.x86_64                                     2.0.1-15.el8                                    @epel      
SDL2_ttf.x86_64                                           2.20.2-1.el8                                    @epel      
SDL2_ttf-devel.x86_64                                     2.20.2-1.el8                                    @epel  

Finally I included
/usr/lib64/libSDL2.a and /usr/lib64/libSDL2main.a .
still no go

what am I missing?

/Björn

You’re not using my SDLAda then, because you don’t need to link anything, you just use the gpr files or alire.

Hi Lucretia.
Is not https://github.com/ada-game-framework/sdlada yours?

is says in the README

You’ll also need to add -lSDL2_image , -lSDL2_ttf and -lSDL2_mixer for your platform. TODO: Fix this.

I am using the gpr-file, otherwise it would not compile I think

I see that is less than clear in my post.
I show what gprbuild made of processing
gprbuild -v -j0 -p -P moving_sdl.gpr "archimedean_spiral"

the gpr looks like this

with "sdlada";
with "moving";

project Moving_sdl is

   Sub_System := "moving_sdl" ;

   SMR      := "../../" ;
   SMT      := SMR & "/target";

   for Exec_Dir use SMT & "/" & Sub_System ;

   for Source_Dirs use Source_Directories.Moving_sdl_Directories;

   for Object_Dir use Global'Object_Dir & "/" & Sub_System;

   for Main use ("archimedean_spiral.adb");

   package Builder  renames Global.Builder;
   package Compiler renames Global.Compiler;
   package Binder   renames Global.Binder;
   package Linker   renames Global.Linker;
   package Ide      renames Global.Ide;

end Moving_sdl;

where moving.gpr contains
with “global”;
with “source_directories”;

and those define

  • platform
  • db
  • compiler warnings
    and they with AWS as well

Still, I don’t get how to link towards the sql-libs unless it is stated in the
gpr. and it is not.
there is a pragma linker option in sdl_linker.ads
but it contains only
Options : constant String := “-lSDL2”;
not the -lSDL2_image , -lSDL2_ttf and -lSDL2_mixer

I think I’ll try to scale it down a bit - and see if I can make just the sdl-part to link

/Björn

Yeah, it is mine, I looked at your output and wondered what that was.

The only thing I can think of is that you’re using an older version of sdlada, grab the master branch. Check “SDL.Video.Rectangles” for those functions, make sure they’re there.

You only need the main lib SDLAda to build that demo, I just tried it with alire.

Also, check the sdlada/src/link directory, this is where the linker options are. If you don’t have them, you need an updated version.

I don’t have the same setup as you, but I did the following:

  1. Installed SDL2 via pacman package manager
  2. Cloned the master branch of sdlada: https://github.com/ada-game-framework/sdlada.git
  3. CD’ed into the sdlada/build/gnat and did the following command (from the readme): make SDL_PLATFORM=windows SDL_MODE=release
  4. Created a basic project (I didn’t add any linker flags) and at the top of the GPR file I withed the sdlada.gpr file in: with "path_to_folder/sdlada.gpr";
  5. Then I built it and ran it.

It worked out of the box with no linking issues. I didn’t have to add any linker flags that way. I don’t know if that is the correct way to do it, but it worked for me. I was running in msys2 under windows as I don’t have linux, but it is as close as I can get.

1 Like

It is likely me using rocky 8 that is the problem.
Installed mint cinnamon, and created a new gpr,
just withing ‘sdlada’ and now it works
Mint gave me libSDL2-2.0.so.0.3000.0
rocky gave me libSDL2-2.0.so.0.10.0
so there is a difference even if I don’t know the version scheme.

Anyway thanks for the hint and for the binding.

/Björn

1 Like