Thanks @normandunbar
But I’ve yet declared the functions that I use (equivalent to extern “C”).
In Ada it looks like :
procedure Blink (N : Interfaces.Unsigned_32);
pragma Import (C, Blink, "blink");
procedure Delai (Ms : Interfaces.Unsigned_32);
pragma Import (C, Delai, "delai");
function Add (A : Interfaces.Unsigned_32 ;
B : Interfaces.Unsigned_32) return Interfaces.Unsigned_32;
pragma Import (C, Add, "add");
The code with the use of Add() alone is linking without error and runs correctly but if I use in addition the functions Delai and Blink then the linking fails with the previous errors.
These functions call Arduino framework functions digitalWrite and delay :
#include <Arduino.h>
void blink(uint32_t n)
{
for (int i = 0; i < n; i++)
{
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(100); // wait for a second
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(100);
}
}
void delai(uint32_t ms)
{
delay(ms);
}
uint32_t add(uint32_t a, uint32_t b)
{
return a + b;
}
digitalWrite and delay are part of Arduino framework.
@maxgerhardt has made a good tutorial on use of Arduino libraries here : How to generate and use pre-compiled objects
And I understood that I have to link with libFrameworkArduino.a library (in addition of export.c.o that contains my functions add, blink and delay) that is the run time Arduino
This library is well identified by the linker because one see that the linker references it in the error messages :
[link] test_librairie_c_code_ada.adb
c:/users/mbdj/.config/alire/cache/dependencies/gnat_arm_elf_12.2.1_351564ba/bin/…/lib/gcc/arm-eabi/12.2.0/…/…/…/…/arm-eabi/bin/ld.exe: C:\Users\mbdj\Dev\Ada\STM32\test_librairie_c\test_librairie_c_code_c.pio\build\nucleo_f446re\libFrameworkArduino.a(wiring_digital.c.o): in function `pinMode': wiring_digital.c:(.text.pinMode+0x36): undefined reference to `pin_in_pinmap’
And the error concerns functions that I don’t use directly (eg pinMode and pin_in_pinmap) but that the library libFrameworkArduino.a seems to use and that seems to be missing for the linker …
So I guess another Arduino libraries are missing for linking. But I don’t know which ones they are.