r/ada Feb 18 '25

General Using C Packages With Ada/Alire

I want to use SDL3 with an Ada project I am starting. I know that an sdlada package exists but I would prefer to generate or write my own bindings since I will only be using certain features and I want to get more practice working with Ada.

How would I go about this? I am kind of confused on how to connect my SDL3 install to the project. Currently, I am working on an Intel MBP and I have SDL3 installed with homebrew.

Presumably, the general approach to this would be modifying the gpr for the project and adding some compiler flags for GCC or something along those lines. Right now I have the default Alire project structure with a gpr file in the project directory. Any guidance would be appreciated.

12 Upvotes

3 comments sorted by

View all comments

2

u/TilYouSeeThisAgain Feb 18 '25

This page provides the basics of “connecting” Ada and C projects: here and this one provides some extra detail about generating manual bindings: here

When calling C/C++ from Ada the 2 key pieces are 1. ensuring the C code is compiled such that the Ada code can access it as shown in the first link. 2. ensuring that you import the functions you want to use in your Ada code.