Using the IMAS C++ HLI

Making the IMAS C++ HLI available for use

When you’re working with a local installation, you can source the installed environment file:

Set environment variables (replace <install_dir> with the folder of your local install)
source <install_dir>/bin/al_env.sh

Using the Access Layer with your C++ program

The following example program will load the C++ interface to the Access Layer to print the version of the access layer and data dictionary.

imas_hello_world.cpp
// Include the Access Layer
#include "ALClasses.h"
#include <iostream>

// The Access Layer declares types in the IdsNs namespace. For brevity of
// examples we will use it here, even though it is considered bad practice:
// https://stackoverflow.com/questions/1452721/why-is-using-namespace-std-considered-bad-practice
using namespace IdsNs;

int main(int argc, char *argv[]) {
    std::cout << "Hello world!" << std::endl;
    std::cout << "Access Layer version info:" << std::endl;
    std::cout << "  Low level version: " << getALVersion() << std::endl;
    std::cout << "  Data Dictionary version: " << al_dd_version << std::endl;
    std::cout << "  C++ HLI version: " << al_cpp_version << std::endl;

    return 0;
}

If you save this as a file imas_hello_world.cpp, you can compile it as follows:

g++ imas_hello_world.cpp `pkg-config --libs --cflags imas-cpp` -pthread -o imas_hello_world

We use pkg-config to output the required libraries and compiler flags to use the C++ Access Layer. Feel free to use a different compiler than gcc, and/or add additional compilation flags to your liking.

Note

al-* package names (e.g., al-cpp, al-identifiers-cpp) are also available as symlinks and work identically to their imas-* counterparts.

When the compilation is successful, a program imas_hello_world was compiled for you. When you execute it, the result is:

$ ./imas_hello_world
Hello world!
Access Layer version info:
  Low level version: 5.0.0
  Data Dictionary version: 3.39.0
  C++ HLI version: 5.0.0

Congratulations if this runs successfully! You have included the C++ Access Layer successfully in a program. In the next sections of the documentation you can see how to: