Skip to content

MindConnect Library – Replacing MCL Modules

Agent developers can provide custom implementations for the following modules and configure MCL build to use custom implementations in place of the default implementations.

HTTP Client

LibCurl is set as the default HTTP client library in MCL which can be replaced by implementing the functions declared in mcl_core/include/mcl_core/mcl_http_client.h. Default implementation is located in mcl_core/src/http_client/curl/http_client_libcurl.c. Note that default http client implementation depends on OpenSSL for TLS.

You may place your implementation in:

a) a subfolder under mcl_core/src/http_client/ so that the directory structure looks like:

1
2
3
4
5
6
7
+-- mcl_core
    +-- src
        +-- http_client
            +-- curl
            +-- <your_implementation_folder>
                +-- <your_source_file(s)>
                +-- CMakeLists.txt
In this case, MCL can be configured to use the alternative implementation by setting -DMCL_HTTP_CLIENT=<your_implementation_folder> when building MCL.

b) any place out of MCL project so that the directory structure looks like:

1
2
3
4
5
6
7
8
9
+-- mcl_core
    +-- src
        +-- http_client
            +-- curl

+-- <any_place_out_of_MCL>
    +-- <your_implementation_folder>
        +-- <your_source_file(s)>
        +-- CMakeLists.txt
In this case, MCL can be configured to use the alternative implementation by setting -DMCL_HTTP_CLIENT=<absolute_path_to_your_implementation_folder> when building MCL.

If you are using CMake to build MCL, you also need to provide CMakeLists.txt file within your alternative implementation directory. CMakeLists.txt file must set the parameters MCL_HTTP_CLIENT_INCLUDE_DIRECTORIES, MCL_HTTP_CLIENT_LIBRARIES and MCL_HTTP_CLIENT_SOURCES for PARENT_SCOPE. Typical CMakeLists.txt would look like:

1
2
3
SET(MCL_HTTP_CLIENT_INCLUDE_DIRECTORIES <directory_to_include> <another_directory_to_include> PARENT_SCOPE)
SET(MCL_HTTP_CLIENT_LIBRARIES <library_to_be_linked> <another_library_to_be_linked> PARENT_SCOPE)
SET(MCL_HTTP_CLIENT_SOURCES <your_source_file> <your_another_source_file> PARENT_SCOPE)

If you are using CMake to build MCL, and your alternative implementation depends on another library, do not forget to add the directory (with contents including headers and the binaries) of that library to CMAKE_PREFIX_PATH option when building MCL.

Crypto

OpenSSL is set as the default cryptography library in MCL which can be replaced by implementing the functions declared in mcl_core/src/security.h. Default implementation is located in mcl_core/src/crypto/openssl/security_libcrypto.c.

You may place your implementation in:

a) a subfolder under mcl_core/src/crypto/ so that the directory structure looks like:

1
2
3
4
5
6
7
+-- mcl_core
    +-- src
        +-- crypto
            +-- openssl
            +-- <your_implementation_folder>
                +-- <your_source_file(s)>
                +-- CMakeLists.txt
In this case, MCL can be configured to use the alternative implementation by setting -DMCL_CRYPTO=<your_implementation_folder> when building MCL.

b) any place out of MCL project so that the directory structure looks like:

1
2
3
4
5
6
7
8
9
+-- mcl_core
    +-- src
        +-- crypto
            +-- openssl

+-- <any_place_out_of_MCL>
    +-- <your_implementation_folder>
        +-- <your_source_file(s)>
        +-- CMakeLists.txt
In this case, MCL can be configured to use the alternative implementation by setting -DMCL_CRYPTO=<absolute_path_to_your_implementation_folder> when building MCL.

If you are using CMake to build MCL, you also need to provide CMakeLists.txt file within your alternative implementation directory. CMakeLists.txt file must set the parameters MCL_CRYPTO_INCLUDE_DIRECTORIES, MCL_CRYPTO_LIBRARIES and MCL_CRYPTO_SOURCES for PARENT_SCOPE. Typical CMakeLists.txt would look like:

1
2
3
SET(MCL_CRYPTO_INCLUDE_DIRECTORIES <directory_to_include> <another_directory_to_include> PARENT_SCOPE)
SET(MCL_CRYPTO_LIBRARIES <library_to_be_linked> <another_library_to_be_linked> PARENT_SCOPE)
SET(MCL_CRYPTO_SOURCES <your_source_file> <your_another_source_file> PARENT_SCOPE)

If you are using CMake to build MCL, and your alternative implementation depends on another library, do not forget to add the directory (with contents including headers and the binaries) of that library to CMAKE_PREFIX_PATH option when building MCL.

File Utility

MCL uses standard C Library as the default file utility for file operations which can be replaced by implementing the functions declared in mcl_core/include/mcl_core/mcl_file_util.h. Default implementation is located in mcl_core/src/file_util/standard/file_util.c.

You may place your implementation in:

a) a subfolder under mcl_core/src/file_util/ so that the directory structure looks like:

1
2
3
4
5
6
7
+-- mcl_core
    +-- src
        +-- file_util
            +-- standard
            +-- <your_implementation_folder>
                +-- <your_source_file(s)>
                +-- CMakeLists.txt
In this case, MCL can be configured to use the alternative implementation by setting -DMCL_FILE_UTIL=<your_implementation_folder> when building MCL.

b) any place out of MCL project so that the directory structure looks like:

1
2
3
4
5
6
7
8
9
+-- mcl_core
    +-- src
        +-- file_util
            +-- standard

+-- <any_place_out_of_MCL>
    +-- <your_implementation_folder>
        +-- <your_source_file(s)>
        +-- CMakeLists.txt
In this case, MCL can be configured to use the alternative implementation by setting -DMCL_FILE_UTIL=<absolute_path_to_your_implementation_folder> when building MCL.

If you are using CMake to build MCL, you also need to provide CMakeLists.txt file within your alternative implementation directory. CMakeLists.txt file must set the parameters MCL_FILE_UTIL_INCLUDE_DIRECTORIES, MCL_FILE_UTIL_LIBRARIES and MCL_FILE_UTIL_SOURCES for PARENT_SCOPE. Typical CMakeLists.txt would look like:

1
2
3
SET(MCL_FILE_UTIL_INCLUDE_DIRECTORIES <directory_to_include> <another_directory_to_include> PARENT_SCOPE)
SET(MCL_FILE_UTIL_LIBRARIES <library_to_be_linked> <another_library_to_be_linked> PARENT_SCOPE)
SET(MCL_FILE_UTIL_SOURCES <your_source_file> <your_another_source_file> PARENT_SCOPE)

If you are using CMake to build MCL, and your alternative implementation depends on another library, do not forget to add the directory (with contents including headers and the binaries) of that library to CMAKE_PREFIX_PATH option when building MCL.

Memory

MCL uses standard C Library as the default utility for memory operations which can be replaced by implementing the functions declared in mcl_core/include/mcl_core/mcl_memory.h. Default implementation is located in mcl_core/src/memory/standard/memory.c.

You may place your implementation in:

a) a subfolder under mcl_core/src/memory/ so that the directory structure looks like:

1
2
3
4
5
6
7
+-- mcl_core
    +-- src
        +-- memory
            +-- standard
            +-- <your_implementation_folder>
                +-- <your_source_file(s)>
                +-- CMakeLists.txt
In this case, MCL can be configured to use the alternative implementation by setting -DMCL_MCL_MEMORY=<your_implementation_folder> when building MCL.

b) any place out of MCL project so that the directory structure looks like:

1
2
3
4
5
6
7
8
9
+-- mcl_core
    +-- src
        +-- memory
            +-- standard

+-- <any_place_out_of_MCL>
    +-- <your_implementation_folder>
        +-- <your_source_file(s)>
        +-- CMakeLists.txt
In this case, MCL can be configured to use the alternative implementation by setting -DMCL_MEMORY=<absolute_path_to_your_implementation_folder> when building MCL.

If you are using CMake to build MCL, you also need to provide CMakeLists.txt file within your alternative implementation directory. CMakeLists.txt file must set the parameters MCL_MEMORY_INCLUDE_DIRECTORIES, MCL_MEMORY_LIBRARIES and MCL_MEMORY_SOURCES for PARENT_SCOPE. Typical CMakeLists.txt would look like:

1
2
3
SET(MCL_MEMORY_INCLUDE_DIRECTORIES <directory_to_include> <another_directory_to_include> PARENT_SCOPE)
SET(MCL_MEMORY_LIBRARIES <library_to_be_linked> <another_library_to_be_linked> PARENT_SCOPE)
SET(MCL_MEMORY_SOURCES <your_source_file> <your_another_source_file> PARENT_SCOPE)

If you are using CMake to build MCL, and your alternative implementation depends on another library, do not forget to add the directory (with contents including headers and the binaries) of that library to CMAKE_PREFIX_PATH option when building MCL.

Any questions left?

Ask the community


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