1

Currently I am using a hardware that provides me a software package that comes from a DLL. They also provide packages in different languages (Java, C++ and Python) with functions from the DLL, so I am programming my app in Java. I would like to change to Ada but I don't know the way to use the DLL functions or the packages that the company offer me in other languages. Is there a way to do it?

I know I can extract the function names from the DLL, but I don't exactly know how to convert that into an Ada package, or if I can use the packages already made in other languages in any way.

Jacob Sparre Andersen
  • 6,733
  • 17
  • 22
Baspro
  • 35
  • 8
  • Welcome to SO, kindly take a look around and see how to ask a proper question. – PradyumanDixit Oct 14 '18 at 12:00
  • Thank you, I guess this is more specific now – Baspro Oct 14 '18 at 12:32
  • There are several questions and answers in the Ada section of SO that relate to interfacing languages with Ada. Most of the time, DLL interfaces are made C compatible. In that case, the writing of the Ada specification of the DLL interface (i.e. for the dll `foo.dll`, write `foo.ads`) can usually be done using the `Interface.C` package and its subpackages. You can find some hints about its usage here, or directly into the Interfaces.C source code : https://stackoverflow.com/questions/42938883/interface-ada-dynamic-library-with-java-using-jna-and-adas-interface-c-packages?rq=1 – LoneWanderer Oct 28 '18 at 21:50

1 Answers1

2

The lazy answer is simply "yes". :-)

The GCC documentation on the subject is here: https://gcc.gnu.org/onlinedocs/gnat_ugn/Using-DLLs-with-GNAT.html

As it says, you also need an Ada specification for the functions in the DLL, you want to use. You can either write it by hand, or use gcc -fdump-ada-spec on the C or C++ header files to have one generated automatically. The generated specifications are not always beautiful, but they are more likely to be correct than something you write from scratch yourself.

Jacob Sparre Andersen
  • 6,733
  • 17
  • 22