Visual Servoing Platform  version 3.5.0 under development (2022-02-15)
Tutorial: How to create and build a project that uses ViSP without CMake
Note
We assume in this tutorial that you have successfully installed ViSP either with an Installation from prebuild SDK or with an Installation from source.

In this tutorial you will learn how to use ViSP without using CMake.

Using a classical Makefile

There are two ways to integrate ViSP as a 3rd-party in a Makefile:

  • either using pkg-config over visp.pc file that you may find in ViSP installation folder; typically in /usr/local/lib/pkgconfig folder,
  • either using visp-config shell script file that you may find in ViSP build folder; typically in $VISP_WS/visp-build/bin folder.

Using pkg_config

  • To get compiler flags use:
    $ pkg-config --cflags visp
    
  • To get linker flags use:
    $ pkg-config --libs visp
    
Note
If visp.pc file used by pkg-config is not found, you may set PKG_CONFIG_PATH environment variable with the path to access to visp.pc using a command similar to:
$ export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:<visp install tree>/lib/pkgconfig

To build a file named HelloWorld.cpp, both command could be used in a Makefile which content would be the following:

CXX            = g++
VISP_CFLAGS    = `pkg-config --cflags visp`
VISP_LDFLAGS   = `pkg-config --libs visp`

HelloWorld: HelloWorld.cpp
    $(CXX) $(VISP_CFLAGS) -o HelloWorld HelloWorld.cpp $(VISP_LDFLAGS)

clean:
    rm -f *~ HelloWorld

Using visp-config

  • To get compiler flags use:
    $ cd $VISP_WS/visp-build
    $ visp-config --cflags visp
    
  • To get linker flags use:
    $ visp-config --libs visp
    

To build a file named HelloWorld.cpp, both command could be used in a Makefile which content would be the following:

CXX            = g++
VISP_BUILD_DIR = ${VISP_WS}/visp-build
VISP_CFLAGS    = `$(VISP_BUILD_DIR)/bin/visp-config --cflags`
VISP_LDFLAGS   = `$(VISP_BUILD_DIR)/bin/visp-config --libs

HelloWorld: HelloWorld.cpp
    $(CXX) $(VISP_CFLAGS) -o HelloWorld HelloWorld.cpp $(VISP_LDFLAGS)

clean:
    rm -f *~ HelloWorld

Next tutorial

You are now ready to see the Tutorial: How to display an image in a window. There is also the Tutorial: How to extend ViSP creating a new contrib module that could be useful to understand how to introduce new developments in ViSP.