From Wikibooks, open books for an open world
Jump to: navigation, search

Ada is a programming language defined in ISO/IEC 8652:2012.

Ada can call C libraries directly. The following program glpkversion.adb invokes glp_version() to output the version of the GLPK library.

with Ada.Text_IO; use Ada.Text_IO;
with Interfaces.C; use Interfaces.C;
with Interfaces.C.Strings;

procedure glpkversion is

  function glp_version return Interfaces.C.Strings.chars_ptr;
  pragma Import (C, glp_version, "glp_version");

end glpkversion;

Compile, bind and link it with

gcc -c glpkversion.adb
gnatbind glpkversion
gnatlink -lglpk glpkversion

A more elaborate example of using GLPK with Ada may be found in the Futoshiki application in KuKu3.