Skip to content

Building MEL for Windows

Evan Pezent edited this page Feb 24, 2019 · 8 revisions

Note: This guide assumes you've already downloaded cmake, git, and cloned the MEL master repository (see Getting Started).

Required Setup and Installation

Note: Quanser DAQs only support Windows.

You will first need to download and install the Microsoft Visual Studio IDE which optionally comes with the MSVC C++ toolchain. Be sure to check the options for installing the C++ language during the installation. Quanser's hardware SDK was built with this compiler, so the MSVC compiler must be used when building MEL for Quanser hardware.

MEL requires that you have Quanser's HIL SDK installed. The SDK contains the necessary device drivers, C/C++ headers and static libraries. There are two options for obtaining the SDK: 1) as a part of Quanser's QUARC MATLAB/Simulink software, or 2) as a standalone installation obtained by contacting Quanser directly (or if you are a MAHI Lab member, this can be found in the MAHI Box drive). Note that MEL Quanser support has no dependency on MATLAB/Simulink, but QUARC may require that they are installed to successfully complete its own installation. The HIL SDK standalone can be installed without MATLAB present.

After installing, ensure that the HIL C/C++ headers and static libraries are located in the following locations:

C:/Program Files/Quanser/QUARC/include      # header files
C:/Program Files/Quanser/QUARC/lib/windows  # 32-bit libraries
C:/Program Files/Quanser/QUARC/lib/win64    # 64-bit libraries

or

C:/Program Files/Quanser/HIL SDK/include      # header files
C:/Program Files/Quanser/HIL SDK/lib/windows  # 32-bit libraries
C:/Program Files/Quanser/HIL SDK/lib/win64    # 64-bit libraries

You may also want to ensure that your Quanser hardware is successfully recognized by Windows by checking for its existence in Device Manager under Universal Serial Bus controllers when it is plugged in and powered on.

Note: If you prefer to install QUARC elsewhere, make sure you update the expected path at the top of MEL's CMakeLists.txt.

Generating Build Files with CMake

Open command prompt in the root MEL folder (e.g. C:/Git/MEL/)) and run the following commands:

> mkdir build  # make new directory for our out-of-place build
> cd build     # change directory to ./MEL/build

Note: Here we have named our build folder build. We could have named this folder anything, and if you plan to build MEL for multiple devices/platforms, it's suggested you use a unique name such as build-quanser, build-myrio, etc.

Now we call CMake to generate our build files. You must pass the -DQUANSER=ON option to tell CMake to link MEL to the HIL SDK. More than likely you will want to use the following command:

> cmake .. -G "Visual Studio 15 2017 Win64" -DQUANSER=ON -DEXAMPLES=ON

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 -D[OPT]=ON turns the specified option on. Consult the Getting Started page to see what other general CMake options are available.

Once 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 MEL from the generated files.

Building

There are a couple of options here. The easiest is to let CMake's build command do all the hard work. In the same terminal as before:

> cmake --build . --config Release

Under the hood, this calls the MSVC compiler to build MEL in the Release configuration. You could also use Debug here as well if you wanted to use that configuration instead.

The other option is to just open the generated MEL.sln file located in the MEL/build folder, with which you can use Visual Studio's GUI interface to build MEL. You can find multiple tutorials for using Visual Studio online.

In either case, the MEL library binary will be compiled to MEL/build/Release/MEL.dll and example binaries will be compiled to MEL/build/examples/Release/*.exe. To run examples, you will need to ensure that the examples can access MEL.dll. The easiest way to do this is to move MEL.dll to the same location as the example binaries. A more permanent solution is to add MEL.dll to the globally visible location C:/Windows/System32 and register it.

Note: If you have the MOVE_BINS CMake option enabled, MEL.lib will be moved to MEL/lib/ and MEL.dll and example/test applications will be moved to MEL/bin after compilation. This is convenient if you only intend to build MEL for a single platform. If you are building for multiple platforms (e.g. cross compiling multiple NI architectures), this is not a good idea as the binaries will overwrite and or conflict with each other.

Clone this wiki locally