Repository navigation
Building mahi util
Previous: Getting Started
Note: These steps are not required for using mahi-util as a part of your code-base, but this process will build the examples for you, and will give you an opportunity to explore the
This guide assumes you've already downloaded cmake, git, and the msvc compiler (see Getting Started). We would also recommend that you have VS Code installed, but it is not necessary.
The first thing you want to do is to get the files from github, and put them on your own computer. Github is based on the open source tool, git, which you installed in Getting-Started. In general, we recommend (but don't require) you store all repositories pulled from github in a general location, like C:/Git/. We will assume you are working in that directory for the rest of the tutorial.
To start, open a powershell terminal and move to the C:/Git/ directory. From there, you can use the git command to directly copy the source code directly from the desired repository to a new folder with the same name as the repository.
> cd C:/Git/
> git clone https://github.com/mahilab/mahi-utilFrom there, we recommend you open the folder C:/Git/mahi-util in the VS Code IDE, but we will provide the instructions to handle it with or without the IDE.
Open a powerhsell terminal (or use the one from before) and run the following commands:
> cd C:/Git/mahi-util/ # navigate to the mahi-util folder
> mkdir build # make new directory for our out-of-place build
> cd build # change directory to ./mahi-util/buildNote: Here we have named our build folder
build. We could have named this folder anything, and if you plan to build your work for multiple devices/platforms, it's suggested you use a unique name such asbuild-quanser,build-myrio, etc.
> cmake .. -G "Visual Studio 16 2019" -A x64 # 64-bit compile (you probably want this)
> cmake --build . --config Releaseor
> cmake .. -G "Visual Studio 16 2019" -A Win32 # 32-bit compile
> cmake --build . --config ReleaseIn the event you are using a newer version of cmake and get an error during compiling, you can use the following commands to force the use of an older version of cmake to avoid the configuration error.
> cmake -S .. -B . -G "Visual Studio 16 2019" -A x64 "-DCMAKE_POLICY_VERSION_MINIMUM=3.5" # 64-bit compile (you probably want this)
> cmake --build . --config Release
or
> cmake -S .. -B . -G "Visual Studio 16 2019" -A Win32 "-DCMAKE_POLICY_VERSION_MINIMUM=3.5" # 32-bit compile
> cmake --build . --config Release
Breaking these commands down, cmake .. calls CMake and tells it to look one directory up for CMakeLists.txt, -G "[GENERATOR STRING]" sets the generator, and -A [PLATFORM] defines the target platform you are developing for. CMake:
The CMake output should look something like this:
-- Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.18363.
-- The C compiler identification is MSVC 19.24.28316.0
-- The CXX compiler identification is MSVC 19.24.28316.0
...
Building mahi::util examples
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/nbd2/Desktop/mahi-util/buildOnce CMake has completed, the build folder will be populated with all of the necessary build files among other CMake specific files. Next, we move on to building mahi-util and examples from the generated files.
In the same terminal as before:
> cmake --build . --target install --config ReleaseUnder the hood, this calls the MSVC compiler to build mahi-util in the Release configuration, as well as building all of the examples. These will be located in mahi-util\build\Release and mahi-util\build\examples\Release, respectively. You make also wish to build in the Debug configuration as well:
> cmake --build . --config DebugNote: If you decided to install the VS Code, then you can do these steps using commands there instead. See Setting Up a Visual Studio Code IDE for more details