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 C 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:


We will now build the C sample located in samples\c, 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:

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 c_sample.c, this is the command line we need:

C:\src>cl.exe /EHsc /MD /I include samples\c\c_sample.c /link /libpath:lib\x64 tobii_interaction_lib_c.lib

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

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

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

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

Please note, when building with gcc, you may have to explicitely make sure pthreads gets linked, like so:

gcc -Iinclude -Llib/x64 samples/c/c_sample.c -o c_sample -ltobii_interaction_lib_c -ltobii_interaction_lib -ltobii_stream_engine -Wl,--no-as-needed -pthread

Reference Documentation

The contents of the sample file c_sample.c is looked at in detail in the Sample walkthrough