TinyMAT
a library to write Matlab MAT-files
Usage/Linking Instructions

Table of Contents

This page explains how to link against TinyMAT.

After building and installing TinyMAT you have all files that you need inside the instal directory:

  • <INSTALLDIR>/include contains all required header files
  • <INSTALLDIR>/bin contains the shared libraries
  • <INSTALLDIR>/lib contains the link libraries
  • <INSTALLDIR>/lib/cmake contains files necessary for CMake's find_package() to work

Build using CMake

When using CMake to build you application, you can simply use target_link_libraries() to link against TinyMAT and use CMake's find_package() to enable that (see https://github.com/jkriege2/TinyMAT/tree/master/examples/extcmake_tinymat_test for an example):

project(extcmake_tinymat_test CXX)
cmake_minimum_required(VERSION 3.0)
set(EXAMPLE_NAME extcmake_tinymat_test)
# if you built with CMake and Qt5 support, you also need to include these packages
find_package(Qt5 COMPONENTS Core REQUIRED)
find_package(OpenCV)
# now find TinyMAT
find_package(TinyMAT REQUIRED)
# add an executable
add_executable(${EXAMPLE_NAME} extcmake_tinymat_test.cpp)
# link against TinyMAT
target_link_libraries(${EXAMPLE_NAME} TinyMAT)

Note that you may have to provide the CMake variables TinyMAT_DIR (or TinyMATShared_DIR) to <INSTALLDIR>/lib/cmake/TinyMAT so CMake finds the TinyMATConfig.cmake file there.

Use TinyMAT without CMake

You can also link against TinyMAT without using CMake. For this you simply have to supply the library as a parameter to your compile/link run, e.g. for GCC:

$ g++ main.cpp -o out -I<INSTALLDIR>/include -L<INSTALLDIR>/lib -lTinyMAT_Release

The -I -option provides the search directory for include-files (i.e. headers) and the -L -option the search path for the link libraries. Here we link against the release version TinyMAT_Release, i.e. with config-decorated filename (see build options!). Check for the actual name of the libs on your system and plug in the appropriate name! If you build the library as a shared lib, you have to link e.g. against TinyMATShared_Release, as the build-scripts add the word hared to the library name for shared libs to distinguish them from the static libs.

Note that you might also have to provide additional libraries, depending on your system.