-
Notifications
You must be signed in to change notification settings - Fork 3
Building MEL for Windows
Note: This guide assumes you've already downloaded
cmake
,git
, and cloned the MEL master repository (see Getting Started).
You will need a compatible Microsoft Visual C++ (MSVC) compiler. While other compilers exist (MinGW, Clang, etc.), the majority of the hardware API's MEL 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 MEL-flavored VS Code)
> choco install visualstudio2017-workload-vctools
- Download the full Visual Studio Community IDE
> choco install visualstudio2017-workload-nativedesktop
MEL's CMake build environment automatically scans your system to determine what hardware APIs you have installed and thus what hardware it can build sub-modules for. Therefore, if you intend to use a particular DAQ or device in MEL, you need to have the correct software installed prior to building. Expand the sections below for the hardware you want MEL to support:
Quanser HIL (Q2-USB, Q8-USB, Q-PID)
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 which can be downloaded from Quanser's HIL SDK repository.
Note: 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: MAHI Lab members can the HIL SDK in the MAHI Box Drive
National Instruments DAQmx
Download and install the NI-DAQmx 18.6 Full (32-bit & 64-bit) drivers and APIs. Ensure that the following directory exits upon completion:
C:\Program Files (x86)\National Instruments\Shared\ExternalCompilerSupport\C
Note: MEL support for NI DAQmx is currently a work in progress. Use with caution.
Thalmic Labs Myo
Download the Windows SDK 0.9.0. Place the zipped folder myo-sdk-win-0.9.0
in C:/Program Files/
. The full path should be:
C:/Program Files/myo-sdk-win-0.9.0/
and should contain folders bin
, include
, lib
, etc. The Myo SDK is linked dynamically, meaning your programs will need to access myo32.dll
or myo64.dll
. You can either copy these files to the directories of your applications, or make a one-time copy to C:/Windows/System32
(for myo64.dll
) or C:\WINDOWS\SysWOW64
(for myo32.dll
) and register the DLLs in an Administrator command prompt:
C:\WINDOWS\system32> regsvr32 myo64.dll
C:\WINDOWS\SysWOW64> regsvr32 myo32.dll
Note: No, that's not a typo. The 64-bit DLL goes in
system32
, and the 32-bit DLL goes inSysWOW64
. Thanks, Microsoft.
After you've installed all the hardware APIs you want, open an Administrator terminal 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 asbuild-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" -DMEL_EXAMPLES=ON # 64-bit compile (you probably want this)
or
> cmake .. -G "Visual Studio 15 2017" -DMEL_EXAMPLES=ON # 32-bit compile
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. MEL provides the following options when building with CMake:
CMake Option | Effect |
---|---|
MEL_EXAMPLES |
Builds MEL example applications |
MEL_DISABLE_LOG |
Disables MEL's built in error logging system |
MEL_BUILD_DOC |
Builds MEL's HTML documentation (Doxygen must be installed) |
The CMake output should look something like this:
-- Selecting Windows SDK version 10.0.17763.0 to target Windows 10.0.17134.
-- The C compiler identification is MSVC 19.16.27027.1
-- The CXX compiler identification is MSVC 19.16.27027.1
...
Building MEL::MEL
-- Found HIL: C:/Program Files/Quanser/QUARC/lib/win64/hil.lib
Building MEL::quanser
-- Found Myo: C:/Program Files/myo-sdk-win-0.9.0/lib/myo64.lib
Building MEL::myo
Building MEL examples
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Git/MEL/build
Here you can see that the core MEL library, MEL::MEL
will be built. In addition, HIL and Myo SDKs were found, so the sub-module libraries MEL::quanser
and MEL::myo
will also be built. Additional sub-module libraries will not be built if the appropriate SDKs cannot be located.
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.
In the same terminal as before:
> cmake --build . --target install --config Release
Under the hood, this calls the MSVC compiler to build MEL in the Release
configuration. It then installs MEL's libraries, header files, and examples to your system in either C:/Program Files/
or C:/Program Files (x86)/
. You make also wish to build and install the Debug
configuration as well:
> cmake --build . --target install --config Debug
Note: If you decided to install the Visual Studio IDE, you can optionally open the generated
MEL.sln
inMEL/build/
and build from the GUI interface.