To write programs using the Framegrabber API a set of tools for compiling and linking programs written in C/C++ is required. For Microsoft Windows, the Framegrabber API comes with support for the Microsoft C/C++ compiler toolchains and in most projects the Microsoft Visual Studio Integrated Development Environment (IDE) will be used.
When using the Linux operating system, the GNU C/C++ and Clang compiler toolchains are supported. These can usually be installed using the package manager that comes with the Linux distribution. Consult the documentation for the Linux distribution, specific online forums and communities.
The code examples in this document generally assume that a modern C++ compiler with support for at least the C++11 standard will be used. If strict C compilation is required, see chapter Considerations When Using Plain C for more information.
When installing the Framegrabber SDK, usually an environment variable BASLER_FG_SDK_DIR is registered with the system, which will be used in the following to denote the location of the Framegrabber SDK installation.
If the Linux operating system is used, the script setup_siso_env.sh will setup the environment variables and can be added to the startup scripts by the system administrator. Due to the variations in startup used by different distributions, this isn't done automatically. If the script isn't called automatically when the system is started or a user logs on, you have to source the script manually both to compile and run applications using the Framegrabber API.
The Framegrabber API needs operating system drivers to access the frame grabbers installed in the computer. On Microsoft Windows, the drivers can be installed using the Framegrabber SDK installer. When using the Linux operating system, the drivers have to be downloaded, compiled and installed separately. Follow the INSTALL document in the Linux driver package for details on how to compile and install the drivers.
When using Microsoft Visual Studio, you can start with a new project and select the "Empty Project" template from the "Visual C++" category. To use the libraries in the project which will be generated, first the directory %BASLER_FG_SDK_DIR%\include should be added to the include paths used by the compiler.
Info
Always make sure that the target platform matches the Framegrabber SDK platform you are using. For Framegrabber SDK, it is always 64-bit.
Next, the directory %BASLER_FG_SDK_DIR%\lib\visualc should be added to the library paths used by the linker.
To link against a library in a Microsoft Visual Studio project it has to be added to the dependencies in the linker settings. In the following example the library fglib5.lib is added:
To add dependencies, you can click on the Button, and select <Edit...>.
When using the Linux operating system and the gcc or clang compilers, the switch -I $BASLER_FG_SDK_DIR/include adds the Framegrabber API include directory to the compiler settings, and the switch -L $BASLER_FG_SDK_DIR/lib adds the Framegrabber API library directory to the linker settings.
To link against a library when using the gcc or clang compilers, the switch -l is used. For example, -l fglib5 adds the library libfglib5.so to the linker dependencies. Given a source code file main.cpp, to compile and link the file into the executable SimpleExample, the following command can be entered on the command line:
CMake is a tool to generate project files from a simple text description of the project requirements for many integrated development environments (IDEs), such as Microsoft Visual Studio, as well as a build workflow using tools like make.
The Framegrabber API comes with files to support the CMake FIND_PACKAGE command. Given a source code file main.cpp, a simple CMakeLists.txt file for a project to compile and link the file into the executable SimpleExample could look like this:
To process the file CMakeLists.txt to generate a project for Microsoft Visual Studio, either the GUI tool can be used, or the project files can be generated by entering on the command line: