-
Notifications
You must be signed in to change notification settings - Fork 0
Getting Started
The MAHI Lab (mainly Evan) has created several main libraries that take care of many of the cumbersome parts of code creation. These libraries are segmented so that you can include just what you need in your library or experiment. The available libraries you will likely use are named with the convention mahi-{descriptor} and are described below
- mahi-util: basic utilities necessary for most programs, i.e. command-line arguments support, logging, time, etc.
- mahi-com: communication protocols, i.e. serial, TCP, UDP, MelShare, etc.
- mahi-daq: to interface with many daqs we have in the lab, i.e. Qaunser Q2, Quanser Q8, NI myRIO, Sensoray
- mahi-gui: to make guis for any application including real-time plotting, experiment interface, hardware dashboards, etc.
You might not need to directly edit the libraries above, but it is good to know how to find them and navigate through them so that you can use them effectively. Also, the examples provided in these libraries are a great resource to see how the features work, so it is nice to have those available.
There are several ways to download and install all of the software you need to get started. One of the easiest ways to get started is to use Chocolatey.
To get started, download and install Chocolatey, a package manager for Windows similar to Linux's apt-get
. Throughout this guide, we will use Chocolatey to install most of our needed software, but a direct link will always be provided to download and install the software manually if you prefer.
Note: Always run Chocolatey from an Administrator Command Prompt or PowerShell terminal. You can do this by right-clicking the Desktop, Start Menu, or Taskbar icon for the terminal and choosing
Run as Administrator
. Also, when installing command-line tools, it may be necessary to restart your terminal before the tool will become usable.
The first program we need is Git, which provides command-line source control and an interface to GitHub so you can download and keep up-to-date with mahi-libs. Download it using Chocolatey (choco
):
> choco install git # install git using Chocolatey
> git --version # make sure Git was installed correctly
mahi-libs uses a very popular tool called CMake to handle the automatic generation of C/C++ build files from mahi-libs source code. These "build files" could be a number of things depending on the target hardware and/or compiler being used with mahi-libs. For example, when using Quanser hardware, mahi-libs must be compiled with Microsoft Visual C++ (MSVC), so we use CMake to generate a Visual Studio solution .sln
file from mahi-libs source files. Likewise, when using National Instruments Linux Real-Time hardware, mahi-libs must be compiled using NI's GNU-based cross-compiler which is incompatible with MSVC or Visual Studio, so we generate a .ninja
file to use with the cross-platform build tool Ninja. Go ahead and install CMake using choco
:
> choco install cmake --installargs 'ADD_CMAKE_TO_PATH=System' # install CMake, adding it to the system PATH
> cmake --version # make sure CMake was installed correctly
We recommend using MSVC as your C++ compiler. There are other options on Windows (gcc, clang), with each providing their own implementations, optimizations, and even some differing features, but most of our codebase has been developed with MSVC in mind.
You will need a compatible Microsoft Visual C++ (MSVC) compiler. While other compilers exist (MinGW, Clang, etc.), the majority of the hardware API's mahi-libs leverages were built with MSVC and thus can only be linked against under MSVC. You have two options for aquiring MSVC:
- Download the the minimum required build tools (recommended for mahi-lib-flavored VS Code)
Go to this Microsoft Visual Studio Download Link, scroll down to "Tools for Visual Studio", and click "Build Tools for Visual Studio 2022" (or later than 2022 if this is in the future).
We recommend using Visual Studio Code to do your code editing. It is an extremely popular code editor that works on Windows, Linux, and macOS, and has a ton of extensions and support so that you can do just about what ever you want in any language.
> choco install vscode # install Visual Studio Code
> code --version # make sure Visual Studio Code was installed properly
Visual Studio Code is a different product than Visual Studio! If you are installing Visual Studio Code without chocolatey, make sure you are getting Visual Studio Code (It is a blue icon) instead of Visual Studio (It has a purple icon).
We will touch more on the Visual Studio Code enviromnet in the section Setting up a Visual Studio Code IDE.