VSM C++ SDK
Vehicle Specific Modules SDK
Building VSM C++ SDK

General information

C++ VSM SDK is implemented using C++11 language which is also a requirement for SDK users code.

VSM SDK uses CMake as its build system to keep it platform independent.

Essentially what CMake does is it wraps the platform specific build commands/files under common interface.

System requirements

Currently supported build toolchains/compilers and their respective versions are:

  • Python 2.7
  • CMake 2.8.8 or higher

Windows:

  • MinGW-w64 with GCC 5.2.0+ are recommended.

Linux:

  • GCC 4.8.1+

Mac:

  • GCC 4.9+ from MacPorts

Setting up the build environment

Below are instructions on how to prepare build environment on Windows and Ubuntu Linux. After the required components are installed the workflow is identical on all platforms.

MacOS X

Your should use MacPorts for GCC installation.

curl -O https://distfiles.macports.org/MacPorts/MacPorts-2.3.4.tar.bz2
tar xf MacPorts-2.3.4.tar.bz2
cd MacPorts-2.3.3/
./configure
make
sudo make install
sudo port selfupdate
sudo port install gcc49
sudo port select --set gcc mp-gcc49

After that you can run CMake in the same way as on other platforms.

Windows

MinGW

Download and install the latest MinGW-w64 from http://sourceforge.net/projects/mingw-w64.

Use MinGW installer. When it asks for configuration you should input:

  • Version: 5.2
  • Architecture: your architecture
  • Threads: posix
  • Exception: dwarf for 32-bits, seh for 64-bits.

Make sure mingw bin directory is added to PATH (E.g. C:\mingw\mingw64\bin)

CMake

Get the latest cmake from http://www.cmake.org.

Make sure cmake is added to PATH (E.g. C:\Program Files (x86)\CMake 2.8\bin)

Python

Get the latest Python 2.7 from http://www.python.org/download/

Make sure python is added to PATH (E.g. C:\Python27)

Linux

gcc 4.8 compiler suite

Ubuntu 12.04 does not have gcc4.8 in default repositories. Add the test toolchain repo and install the compilers.

$ sudo add-apt-repository ppa:ubuntu-toolchain-r/test
$ sudo apt-get update
$ sudo apt-get install gcc-4.8
$ sudo apt-get install g++-4.8
$ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 10
$ sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 10

Ubuntu 14.04 has gcc 4.8 in default repositories.

$ sudo apt-get install gcc
$ sudo apt-get install g++

CMake

$ sudo apt-get install cmake

Ubuntu 12.04 has only CMake 2.8.7, so you have to install higher version manually.

$ sudo add-apt-repository ppa:kalakris/cmake
$ sudo apt-get update
$ sudo apt-get install cmake

Python

VSM SDK requires python 2.7 to build.

$ sudo apt-get install python2.7

Eclipse setup (optional)

Eclipse is recommended IDE for all platforms.

You should have the latest Java for eclipse to run.

Some plugins are recommended for the development of VSM SDK itself. They are not required for standalone VSM development.

CMake editor plugin: http://sourceforge.net/projects/cmakeed/

UML diagram plugin: http://plantuml.sourceforge.net/eclipse.html

The vsm-cpp-sdk directory includes eclipse project file which is tuned for underlying build system. To use it go to "File/Import/Existing Projects into Workspace" Eclipse project features:

  1. Same project file can be used on both Linux and Windows.
  2. Custom Targets to create makefiles and build with one click.
  3. Source indexer tuned to support C++11 syntax and correct includes.
  4. Predefined build configurations for win and linux.
  5. .tpignore file which prevents build directories from being added to tfs.

Lastly under Project/Properties/C++General/Preprocessor Includes/Providers: Check the "CDT GCC build output parser" and "CDT GCC built in compiler settings" checkboxes.

Compiling SDK

OEM manufacturers and enthusiasts are supposed to compile the SDK by themselves so source code is provided for them (https://github.com/UgCS/vsm-cpp-sdk), however they are not supposed to modify the SDK sources. If some functionality is missing, it is always worth to contact UgCS and suggest a proposal. Good proposals have a chance to be officially added to the SDK, so everybody can benefit from it. There is no support for Microsoft MSVC compiler due to poor support of C++11 language standard by Microsoft.

CMAKE (http://www.cmake.org/) cross-platform build system is used by VSM C++ SDK. You can use standard CMake variables to change the build process:

  • CMAKE_BUILD_TYPE - possible values are "DEBUG" for debug builds and "RELEASE" for release build.
  • CMAKE_INSTALL_PREFIX - change the installation directory of "make install" target. (Default is "/usr/local/" which installs the SDK in directory "/usr/local/opt/vsm-sdk".)

Python 2.6 (or later from branch 2.x) is needed for make file generation.

Building from command line

For example (assuming current directory is location of your vsm-cpp-sdk source), typical compilation and installation steps of VSM SDK on Linux are the following:

  1. Create build directory and makefiles:

    mkdir build-release-linux
    cd build-release-linux
    cmake -DCMAKE_BUILD_TYPE=RELEASE -G"Unix Makefiles" ..
    

    To generate Doxygen SDK documentation -DVSM_BUILD_DOC=YES should be passed to cmake and additional prerequisites met:

  2. Create build directories and makefiles for unittests:

    cd test/unit
    mkdir build-release-linux
    cd build-release-linux
    cmake  -DCMAKE_BUILD_TYPE=RELEASE -DUTPP_DIR=/path/to/UnitTest++ -G"Unix Makefiles" ..
    

    You should get a copy of UnitTest++ framework from http://unittest-cpp.sourceforge.net/, copy sources to any location and pass it to CMake via UTPP_DIR variable as show in the example above.

  3. Perform the build:
    • Linux release build using 4 CPU cores:
      cmake --build build-release-linux -- -j4
      
  4. Install the release version of SDK on Linux:

    cmake --build build-release-linux --target install
    

    Make sure there is a write permission for an installation folder, which is C:\Program files\vsm_sdk for Windows and /usr/local/opt/vsm-sdk for Linux by default. Default installation path can be overridden by passing a CMake variable CMAKE_INSTALL_PREFIX to the configuration phase.

(These steps can be automated via build targets in eclipse workspace)


Compiling VSM

After SDK is installed, cmake can be used to build VSMs, too (see "Hello world" VSM application).

  • Create build directories and makefiles for vsm (if CMake toolchain is used, make sure to specify VSM_SDK_DIR variable):
     cd your/vsm/source
     mkdir build-release-linux
     cd build-release-linux
     cmake  -DCMAKE_BUILD_TYPE=RELEASE -DVSM_SDK_DIR=/usr/local/opt/vsm-sdk -G"Unix Makefiles" ..
    

Any other build system of user choice can be used to compile VSM with the following settings:

  • SDK include folder: "include" under your VSM_SDK_DIR
  • SDK library folder: "lib" under your VSM_SDK_DIR
  • Additional Linux platform libraries: "rt"
  • Additional Windows platform libraries: "ws2_32 Userenv bfd iberty dbghelp z"
  • SDK library name: "vsm_sdk"

Building VSM SDK for Android

All the previous instructions valid and additionally ANDROID CMake variable should be defined. Also Android NDK should be available and its path either defined in ANDROID_NDK environment variable or passed directly to CMake. E.g. on Linux:

cmake -DANDROID=1 -DANDROID_NDK=/opt/android-ndk-r10e ..

VSM SDK should be installed after compilation as usually. Android native libraries are available in build directory under "android/libs" path after the VSM is built.

Additional CMake and environment variables are accepted for Android build:

  • ANDROID_ABI_LIST can specify semicolon-separated list of target ABI (e.g. "armeabi;armeabi-v7a;x86").
  • ANDROID_PLATFORM can specify target Android platform (e.g. "android-19")