Compiling a Custom IDL Driver

The IDL library itself is implemented as a shared object (.SO) written in C++, as is the associated header file, libidl.h.  It is designed to be compiled with a custom driver application also written in C++ using the GNU compiler (g++).  The SmartServer IoT includes an installed instance of GCC (GNU Compiler Collections) and the g++ compiler.  Using a console application like PuTTY to access the SmartServer IoT, you can verify the installation of g++ by checking the version using the ‘g++ --version’ command from the console. 



The provided example IDL driver includes a simple makefile.  Using the makefile is the easiest way to compile this example driver.  Using a console application, navigate to the /var/apollo/data/example/ directory and simply type ‘make’ to compile the example.



The make file specifies the –g option with g++ in order to include the debugging information in the resulting object / executable file.  For a final driver build, you might exclude this option.  Several library files must also be specified in the compilation process including:

  • idl – The required IDL library.
  • mosquitto – The MQTT message broker library.
  • pthread – The POSIX threading library (if custom driver threads are instantiated).
  • rt – The Linux real-time library.  This is required as the IDL library itself uses message queuing (mqueue).

After compiling the application, the resulting executable ( /.example ) can be found in the /var/apollo/data/example/ directory.

While this documentation section is focused on the basics associated with compiling up the provided example IDL driver, developers are likely aware that there are options for developing & compiling IDL driver source code on a PC, such as a Windows-based PC.  Running an IDL driver on a non-Linux target other than that SmartServer IoT may not be practical, given the close connection between an IDL driver and the underlying hardware and the SmartServer IoT’s CMS, but development environments like Visual Studio Code can facilitate code development.  While there is plenty of information online dedicated to cross-compiling C++ code using GCC (g++), here are a few tools that you might find useful.

The Microsoft C/C++ extension for Visual Studio Code enables cross-platform C and C++ development on Windows and Linux.  This extension can be easily downloaded & installed from within Visual Studio Code.



Mingw-w64 is an open source project and a free runtime environment created to support the GCC compiler (g++) on 32-bit and 64-bit Windows-based systems.  Mingw-w64 can be freely downloaded and installed from the SourceForge website.



During installation, set the architecture to x86_64 and add the path to your Mingw-w64 folder to the Windows PATH environment variable.  You can verify the minGW installation using a Windows console to check the installed version of g++ ‘g++ --version’.

Within Visual Studio Code you can ‘Configure Default Build Task’ from the Terminal and choose g++.exe as the active build file which will create an associated tasks.json file in the .vscode folder.  This ultimately provides a means to build IDL driver code via the ‘Run Build Task’ from the Terminal in Visual Studio Code.