I need to include PDCurses C library into an Ada application

Viewed 179

I have a project which previously utilized a linux platform. It utilized libcurses.a. I have ported it to Windows 10 and compiled the PDCurses and created a library file. I am trying to include this library so I can get rid of the linker problems:

c:/gnat/2020/bin/../libexec/gcc/x86_64-pc-mingw32/9.3.1/ld.exe: C:\GNAT\2020\bin\obj\curses.o:curses.adb:(.text+0x9): undefined reference to `initscr'
c:/gnat/2020/bin/../libexec/gcc/x86_64-pc-mingw32/9.3.1/ld.exe: C:\GNAT\2020\bin\obj\curses.o:curses.adb:(.text+0xe): undefined reference to `m_erase'

There are more but this is just an indication. I am using GNAT Studio from AdaCore. I believe I need to include -lPDCurses.lib in the gnatlink but cannot see where to add it in GNAT Studio.

EDIT: I have code in a specification to pragma Interface the C routines:

pragma INTERFACE (C, INITSCR);
pragma INTERFACE_NAME (INITSCR, "initscr");
1 Answers

If I remember correctly (I didn't use GNAT Studio by some time), in the GNAT Studio, you need to edit in menu Project->Properties (this menu name I'm not sure)->Compilation flags. There should be a text field where you can add flags to the linker.

More advanced way - you can also edit your project file in editor - this one file with extension .gpr and add there:

   package Linker is
      for Default_Switches ("ada") use ("-lPDCurses");
   end Linker;

If -lPDCurses of course is proper flag for PDCurses :)

Related