Skip to content

CMakeBuild

PimenovAlexander edited this page Aug 17, 2020 · 12 revisions

Instruction how to build a project

CI

Continuous integration is partially supported for this build using Github Actions. Please check Status for the build. If the build is ok, most probably problem is on your side. You can use workflow scripts as a reference

Build status for master_cmake branch without OpenCV built with ccpp.yaml

master_cmake -

master_cmake -

apimenov_http -

Build status for opencv_build_instructions branch

Linux

A word on prerequisites. Core of the project has no dependances and should work with C++14. Only prerequisite would be cmake. However if you only need core, you would have to comment out all the other sub-projects.

  • Get git
sudo apt-get install git
  • Get cmake
sudo apt-get install cmake
  • Clone the repository
mkdir student
cd student
git clone https://github.com/PimenovAlexander/corecvs.git .
  • Check if you have prerequisites installed (Qt should be Qt5)
sudo apt-get install qt5-default qt5-qmake gcc g++ 
sudo apt-get install libqt5serialport5-dev

Optional prerequisites.

I recommend installing them, it they are available they would be used automatically.

sudo apt-get install libjpeg-dev libpng-dev libgif-dev
sudo apt-get install libopenblas-dev liblapacke-dev
sudo apt-get install libfftw3-dev libsoapysdr-dev libevent-dev

Optional prerequisites II.

I recommend installing them, otherwise you will have to switch them off using CMake GUI.

Ubuntu Xenial

 
sudo apt-get install libtbb-dev libcv-dev libhighgui-dev graphviz valgrind libxtst-dev
sudo apt-get install libavcodec-dev libavutil-dev libavformat-dev libswscale-dev

Ubuntu Cosmic 18.10

 
sudo apt-get install libtbb-dev libopencv-*3.* graphviz valgrind libxtst-dev
sudo apt-get install libavcodec-dev libavutil-dev libavformat-dev libswscale-dev

QScript

If you get error with qscript module you can add following packages

 sudo apt-get install qtscript-tools qtscript5-dev 

GTest

You will also need to build Google Test (http://askubuntu.com/questions/145887/why-no-library-files-installed-for-google-test), or switch off all tests. This step is done automatically with cmake.

Actual Build

In the root directory of the code please execute

mkdir build
cd build
cmake ..
make

Or on all cores

mkdir build
cd build
cmake ..
make -j
  • Note that building with all cores may cause UI frees and performance degradations on some platforms, so you might want to use
make -j{number of your cores - 1}

as the last step

Third-party libraries

OpenCV

Currently we support OpenCV 3.X You could either build it yourself or install from repository - OpenCV guide

Manual build configuration

CMake allows you to configure your build. Type

ccmake .
in root directory to see the options; hit
t
to see advanced options.
  • WITH_CUSTOM_CONFIGURATION - manually specify the instruction set to be used in generated code. When OFF, configuration will be auto-detected
  • with_sse - allow the compiler and our code to use SSE instructions. Only works when WITH_CUSTOM_CONFIGURATION is ON
  • with_sse3 - allow the compiler and our code to use SSE 3 instructions. Only works when WITH_CUSTOM_CONFIGURATION is ON
  • with_sse4_1 - allow the compiler and our code to use SSE 4.1 instructions. Only works when WITH_CUSTOM_CONFIGURATION is ON
  • with_sse4_2 - allow the compiler and our code to use SSE 4.2 instructions. Only works when WITH_CUSTOM_CONFIGURATION is ON
  • with_avx - allow the compiler and our code to use AVX instructions. Only works when WITH_CUSTOM_CONFIGURATION is ON
  • with_avx2 - allow the compiler and our code to use AVX 2 instructions. Only works when WITH_CUSTOM_CONFIGURATION is ON
  • USE_TBB - whether should use TBB (Intel thread building blocks)
  • USE_OPENBLAS - whether should use BLAS (OpenBlas or MKL)
  • USE_OPENCV - whether should use OpenCV
  • USE_AVCODEC - whether should use Avcodec
  • USE_LIBGPEG - whether should use LibJpeg
  • USE_LIBPNG - whether should use LibPng
  • WITH_OPENGL - whether should use OpenGL

Cleanup

Cleaning might sometimes help to fix creepy errors. Options include:

  • Caution. Burn all non committed and not belonging to work copy to the ground.
    git clean -dfx
  • rm -rf build

Mac

Similar steps might work. The configuration will be auto-detected

Windows

Similar steps might work. The configuration will not be auto-detected, you may want to configure the processor architecture manually

Clone this wiki locally