Skip to content

MindConnect Library – Building MCL

This section will guide you to build MCL as a dynamic library from source code using CMake in Linux environment and also show you how to import and use MCL inside an example agent application. Although the steps are described for Linux environment, they are expected to be informative enough for other environments as well.

Helper scripts and build_helper_win64.bat are distributed with the source code which can be used as reference to setup your host environment and build MCL in Linux and Windows respectively.

Default implementations for replaceable modules (i.e. http client, crypto, memory and file utility) will be used. If you intend to use alternative implementation for any of the replaceable modules see Replacing MCL Modules.

Both the core component and the connectivity extension will be built. See MCL Build Options to select components to build.

These are the steps of the build process in order:

Building OpenSSL

Download OpenSSL package openssl-1.1.1d.tar.gz and in your download directory run the following commands where <OpenSSL_Install_Directory> refers to the directory you want to install OpenSSL:

$ tar -xvzf openssl-1.1.1d.tar.gz
$ cd openssl-1.1.1d
$ ./config --prefix=<OpenSSL_Install_Directory> -Wl,-rpath=<OpenSSL_Install_Directory>/lib shared -fPIC
$ sudo make install

Now, there must be a folder <OpenSSL_Install_Directory>/include/openssl and shared objects <OpenSSL_Install_Directory>/lib/ and <OpenSSL_Install_Directory>/lib/

Building Libcurl

Download libcurl package curl-7.65.3.tar.gz and in your download directory run the following commands where <libcurl_Install_Directory> refers to the directory you want to install libcurl:

$ tar -xvzf curl-7.65.3.tar.gz
$ cd curl-7.65.3
$ LDFLAGS="-Wl,-R<OpenSSL_Install_Directory>/lib" ./configure --enable-http --with-ssl=<OpenSSL_Install_Directory> --prefix=<libcurl_Install_Directory> --without-libssh2 --disable-ftp --disable-tftp --disable-file --disable-ldap --disable-rtsp --disable-dict --disable-telnet --disable-pop3 --disable-imap --disable-smb --disable-scp --disable-sftp --disable-smtp --disable-gopher --disable-manual
$ sudo make install

Now, there must be a folder <libcurl_Install_Directory>/include/curl and shared object <libcurl_Install_Directory>/lib/

Building MCL

After the dependencies of MCL are built, to build MCL, run the following commands where

<MCL_Source_Directory> refers to the directory of MCL source code (i.e. directory in which, top level CMakeLists.txt and subfolders for each component exist),
<MCL_Build_Directory> refers to the intermediate directory used during build process,
<MCL_Install_Directory> refers to the directory in which build artifacts are located.

$ mkdir -p <MCL_Build_Directory>
$ cd <MCL_Build_Directory>
$ cmake --build . --clean-first --target install

Now, there must be folders named mcl_core, mcl_connectivity, mcl_data_lake and mcl_deployment containing MCL headers in \<MCL_Install_Directory>/include and shared objects named,, and in \<MCL_Install_Directory>/lib.

MCL Build Options

You can build MCL with different configurations with the options listed in the table below:

Variable Default Value Description
MCL_STATICLIB OFF If set to ON, MCL components are built as static library.
MCL_DOC OFF If set to ON, MCL reference documentation is also built.
MCL_TEST OFF If set to ON and if ruby is found in path MCL is built with tests.
MCL_CONNECTIVITY ON If set to ON, MCL Connectivity component will also be built.
MCL_DATA_LAKE ON If set to ON, MCL Data Lake component will also be built.
MCL_DEPLOYMENT ON If set to ON, MCL Deployment component will also be built.
MCL_CRYPTO "openssl" See "Replacing MCL Modules" section.
MCL_HTTP_CLIENT "curl" See "Replacing MCL Modules" section.
MCL_FILE_UTIL "standard" See "Replacing MCL Modules" section.
MCL_MEMORY "standard" See "Replacing MCL Modules" section.
MCL_LOG_LEVEL MCL_LOG_LEVEL_INFO MCL logging level. See MCL Logging section.

MCL Logging

MCL logging level can be configured when building MCL by setting MCL_LOG_LEVEL option to one of the values listed in the table below:

MCL Logging Level Description
MCL_LOG_LEVEL_VERBOSE Extensive details of operation are logged together with MCL_LOG_LEVEL_DEBUG level logs.
MCL_LOG_LEVEL_DEBUG Diagnostically helpful information are logged together with MCL_LOG_LEVEL_INFO level logs.
MCL_LOG_LEVEL_INFO Information for the stages of operation are logged together with MCL_LOG_LEVEL_WARN level logs.
MCL_LOG_LEVEL_WARN Warnings are logged together with MCL_LOG_LEVEL_ERROR level logs.
MCL_LOG_LEVEL_ERROR Operational errors are logged together with MCL_LOG_LEVEL_FATAL level logs.
MCL_LOG_LEVEL_FATAL Only fatal errors are logged.
MCL_LOG_LEVEL_NONE Nothing is logged.

Scope of logging can be reduced in agent application code from the level set at build time but can not be extended. See reference documentation for details.

Building Custom Agent Application

MCL source code is distributed with several example agent applications. See Examples for details. To build an example agent application, you can copy the source code of one of the examples to a directory, referred as <Custom_Agent_Project_Directory>, and create a CMakeLists.txt file in that directory with the content below:


# You can change the project name.
PROJECT(CustomAgentApplication LANGUAGES C)



# You must type in the directory that MCL is installed.
SET(MCL_INSTALL_DIR "<MCL_Install_Directory>")



# You can change the name of the executable, it does not have to be the same as the project name.


Now, you can compile your agent application by running the following commands where <Custom_Agent_Build_Directory> refers to the build directory for your project:

$ mkdir -p <Custom_Agent_Build_Directory>
$ cd <Custom_Agent_Build_Directory>
$ cmake <Custom_Agent_Project_Directory>
$ cmake --build . --clean-first

You will find agent application executable named CustomAgentApplication in <Custom_Agent_Build_Directory>.

Building MCL In Specific Environments

Although the default build tool is CMake, MCL is ported to be built as part of other SDK in specific environments. You can build MCL as part of an mbedOS application by importing MCL as a library to your application in mbedOS development environment. You can integrate MCL to Sony Spresense environment to be built together with Sony Spresense SDK by following the document Sony Spresense Guide provided with MCL source code.

Any questions left?

Ask the community

Except where otherwise noted, content on this site is licensed under the MindSphere Development License Agreement.

Last update: March 26, 2021