Integrating MSCL into your project allows you to communicate with and configure MicroStrain Wireless, Inertial, and Displacement sensors. The recommended approach is using CMake, but manual integration is also supported.
MSCL provides a CMake configuration file (mscl-config.cmake) that makes it
easy to find and link the library in your own CMake-based projects.
Ensure you have MSCL installed or built from source. If you built from source,
the mscl-config.cmake file will be located in your build directory.
To use MSCL in a C++ project, use find_package to locate the library and then
link your target to ${MSCL_LIBRARIES}.
Example CMakeLists.txt:
cmake_minimum_required(VERSION 3.16)
project(MyMsclProject)
# Set MSCL_ROOT_DIR to the location where MSCL is installed or built
set(MSCL_ROOT_DIR "/path/to/mscl" CACHE PATH "Path to MSCL")
list(APPEND CMAKE_PREFIX_PATH "${MSCL_ROOT_DIR}")
# Find the MSCL package
find_package(MSCL REQUIRED CONFIG)
add_executable(my_app main.cpp)
# Link to MSCL libraries
target_link_libraries(my_app PRIVATE ${MSCL_LIBRARIES})
# Optional MSCL include directories (implied by target_link_libraries)
target_include_directories(my_app PRIVATE ${MSCL_INCLUDE_DIRS})
# MSCL uses precompiled headers or 'mscl.h' for all-in-one inclusion
target_precompile_headers(my_app PRIVATE "${MSCL_INCLUDE_DIR}/mscl/stdafx.h")For consistency across different integration methods, source built or installed
packages (mscl-config.cmake), the following CMake variables are always
available:
MSCL_LIBRARY: Name of the MSCL library to link against.MSCL_INCLUDE_DIR: Path to the MSCL include directory.MSCL_LIBRARIES: List of MSCL libraries to link against (including MSCL itself).MSCL_INCLUDE_DIRS: List of MSCL include directories.
For C# projects, MSCL provides an MSCL_Managed package.
Example CMakeLists.txt:
cmake_minimum_required(VERSION 3.16)
project(MyMsclCSharpProject LANGUAGES CSharp)
# Set MSCL_MANAGED_ROOT_DIR to the location of MSCL_Managed
set(MSCL_MANAGED_ROOT_DIR "/path/to/mscl" CACHE PATH "Path to MSCL Managed")
list(APPEND CMAKE_PREFIX_PATH "${MSCL_MANAGED_ROOT_DIR}")
# Find the MSCL_Managed package
find_package(MSCL_Managed REQUIRED CONFIG)
add_executable(my_csharp_app Program.cs)
# Use the helper function provided by MSCL_Managed to add references
mscl_managed_add_references(my_csharp_app)If you are not using CMake, you must manually configure your compiler and linker.
-
Include Paths: Add the following to your compiler's include search paths:
<MSCL_ROOT>/src(if using source) or<MSCL_INSTALL>/include(if using installed headers).- Boost include directory (v1.70.0+).
- OpenSSL include directory (if using SSL).
-
Compiler Definitions:
MSCL_WITH_SSL(to enable SSL support).MSCL_WITH_WEBSOCKETS(to enable WebSocket support).
-
Linking:
- Link against the MSCL library (
MSCL.libon Windows,libMSCL.soon Linux).
- Link against the MSCL library (
- Add Reference: In your IDE, add a reference to
MSCL_Managed.dll. - Runtime Dependency: Ensure
MSCL.dll(the native C++ library) is present in the same directory as your application's executable at runtime. - Platform: Ensure your project targets the correct architecture (
x64orx86) to match the MSCL binaries.
Python integration does not strictly require CMake. You just need the MSCL.py
and _MSCL extension module.
-
Locate Files: Find
MSCL.pyand the compiled extension (_MSCL.pydon Windows or_MSCL.soon Linux). -
Add to Path:
- Method A (Recommended): Copy these files into your project directory
or into a standard Python
site-packagesordist-packagesdirectory.- Note: The MSCL Python bindings are packaged using the respective Python
site-packagesordist-packagesdirectories and can be installed directly into those directories
- Note: The MSCL Python bindings are packaged using the respective Python
- Method B (Manual Path): Add the path to the directory containing these files in your Python script:
import sys sys.path.append('/path/to/mscl/python/bindings') import MSCL as mscl
- Method A (Recommended): Copy these files into your project directory
or into a standard Python