The C++ example projects in this repository use CMake.
The following link has the instructions to install CMake.
On Windows, make sure you add CMake to your PATH variable
To check which version of GCC is installed on Windows or Linux
Note: This procedure only works on Windows if you add the MinGW bin directory path to the PATH environment variable.
gcc --version
sudo apt-get install build-essential
Because GCC is not coded for the Windows operating system, a GCC port of MinGW-w64 for Windows is required. The ‘-w64’ suffix indicates that it can support a 32-bit or 64-bit environment. The 32-bit versions are still available and one of them will be used to compile the affected project.
Next
until you reach the installation options pageNext
until the end of the installation. The install directory by default is the one set in the build script included with the project.Start
ButtonSystem
from the context menu.Advanced system settings
Advanced
tabEnvironment Variables…
Path
and click Edit…
New
PATH
(e.g. C:\Program Files (x86)\mingw-w64\i686-5.4.0-posix-dwarf-rt_v5-rev0\mingw32\bin
)The C++ examples use the Conan (V1.X) package manager for fetching its dependencies. This is done by default and requires Conan to be installed.
Instructions are for conan V1.X only and it won’t work for versions >=2.0.0
You can refer to the Conan Installation Tutorial for installing Conan.
Note: It is recommended to install Python3 for Conan. You can download and install Python3 from https://www.python.org/
When installing conan
via pip
the new directory might not be appended to the PATH. This can be solved on Ubuntu by restarting the terminal or by using source ~/.profile
or by adding the installed PATH (that you can find with pip show conan
) to your PATH environnement variable in Windows.
Next, enable the revision feature for Artifactory plugin
conan config set general.revisions_enabled=1
Create an automatically detected default profile
conan profile new default --detect
After Conan is properly installed, build as specified in the build section.
Although building with Conan is recommended, it is possible to disable it.
Doing so requires calling cmake with an additional option: -DUSE_CONAN=OFF
.
Example (Linux):
mkdir build
cd build
cmake .. -DUSE_CONAN=OFF -DCMAKE_BUILD_TYPE=release [-DKORTEX_SUB_DIR=<kortex_api_sub_folder dir name>]
make
This applies to all the manual build commands. The build scripts can also be modified to add this option.
Example (build-mingw.bat)
(line 17) cmake .. -G "MinGW Makefiles" -DUSE_CONAN=OFF -DCMAKE_BUILD_TYPE=%build_type% -DKORTEX_SUB_DIR=%kortex_api_sub_folder% && mingw32-make
This will effectively revert to the old build method. It requires downloading the Kortex Api library:
kortex_api
.examples/kortex_api
┬
├ include/
├ lib/
└ ┬
├ debug/
└ release/
You can also uncompress the content of the archive in a sub-directory kortex_api/<Something>
. You will then have to use the KORTEX_SUB_DIR
CMake argument to specify the Kortex API sub-directory.
examples/kortex_api
┬
├ Something/ [e.g. linux_gcc_x86-64]
└ ┬
├ include/
├ lib/
└ ┬
├ debug/
└ release/
Note: The C++ examples use the Conan package manager by default. Refer to the Conan section on how to install Conan or revert to building without Conan.
To build, you need change the current directory to the example directory. The build instructions then depend on your OS and compiler (see below).
my_example_repo
┬
├ api_cpp/
└ ┬
├ doc/
└ examples/ (you have to cd here)
Linux Ubuntu
You can run the build script:
```
./scripts/build-gcc.sh {release|debug}
```
You can also build manually:
```sh
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=release [-DKORTEX_SUB_DIR=Windows - using GCC
You can run the build script:
```
scripts\build-mingw.bat {release|debug}
```
You can also build manually:
```bat
mkdir build
cd build
cmake .. -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=release [-DKORTEX_SUB_DIR=Windows - using Visual Studio 2017
```sh
mkdir build
cd build
cmake .. -G "Visual Studio 15 2017 [arch]" -DCMAKE_SH=CMAKE_SH-NOTFOUND -DCMAKE_BUILD_TYPE=release [-DKORTEX_SUB_DIR=Windows - using command-line MSVC build
Setup the build environment:
**Note:** Make sure to adjust the path to match the location of your installed BuildTools call:
`C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliary\Build\vcvars64.bat`
You can run the build script:
```
scripts\build-msvc.bat {release|debug} {static|dynamic}
```
You can also build manually:
```bat
mkdir build
cmake .. -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release [-DKORTEX_SUB_DIR=