Tobii Interaction Library SDK

[Back to the SDK start page]

Including the C++ header file and linking with the library file

The Interaction Library SDK is distributed with dynamic 32 bit and 64 bit C++ libraries for Windows, and 64 bit libraries for Linux and macOS. Let's assume we have downloaded a zip file with the SDK version for Windows with a dynamic 64 bit library. We can now unzip this into a directory of our choice, for example C:\src, so that we there have this content:

bin\
include\
lib\
samples\
release_notes.txt

We will now build the C++ sample located in samples\cpp, using the Visual Studio 2017 toolset, to show what C++ header and library files we need.

Using the "x64 Native Tools Command Prompt for VS 2017", this is what we will see when running the compiler without any command line options:

C:\src>cl.exe
Microsoft (R) C/C++ Optimizing Compiler Version 19.16.27027.1 for x64
Copyright (C) Microsoft Corporation. All rights reserved.
usage: cl [ option... ] filename... [ /link linkoption... ]

To build the C++ sample file cpp_sample.cpp, this is the command line we need:

C:\src>cl.exe /EHsc /MD /I include samples\cpp\cpp_sample.cpp /link /libpath:lib\x64 tobii_interaction_lib.lib tobii_stream_engine.lib

The /I include option tells the compiler where to find header files included in the sample, specifically interaction_lib/InteractionLib.h. The /libpath:lib\x64 option tells the linker where to find libraries referenced on the command line, specifically tobii_interaction_lib.lib and tobii_stream_engine.lib.

The output from cl.exe is cpp_sample.exe, which we now can run from the command line. But first we need to copy the two dynamic libraries from the SDK that the C++ sample references:

C:\src>copy lib\x64\tobii_interaction_lib.dll
C:\src>copy lib\x64\tobii_stream_engine.dll
C:\src>cpp_sample.exe

If a Tobii eyetracker is plugged into the computer, we will see gaze focus events getting printed to the command window.

Reference Documentation

The contents of the sample file cpp_sample.cpp is looked at in detail in the Sample walkthrough