Compiling the C++ library with Mbed-TLS 4.0

Compiling the C++ library with Mbed-TLS 4.0

We've just released a new version of our C++ library. The main change in this version is the update of the Mbed-TLS library to version 4.0. As we'll see, this changes the way we compile our library.




Our C++ library uses the Mbed-TLS library for cryptography. The latest version of this library has introduced a change in the source file tree. This forces us to update the procedure for compiling our library.

In concrete terms, to compile our C++ library, you need to compile the following files:

  • the C++ files of the classes you use in the "Sources" directory
  • all C files in the "Sources/yapi" directory
  • all C files in the "Sources/yapi/mbedtls/library" directory
  • all C files in the "Sources/yapi/mbedtls/tf-psa-crypto/core/" directory
  • all C files in the "Sources/yapi/mbedtls/tf-psa-crypto/drivers/builtin/src/" directory


For compilation to work, you must ensure that the following directories are part of the include path:

  • the "Sources" directory
  • the "Sources/yapi/mbedtls/include" directory
  • the "Sources/yapi/mbedtls/tf-psa-crypto/core" directory
  • the "Sources/yapi/mbedtls/tf-psa-crypto/drivers/builtin/include" directory
  • the "Sources/yapi/mbedtls/tf-psa-crypto/drivers/builtin/src" directory
  • the "Sources/yapi/mbedtls/tf-psa-crypto/include" directory


Finally, under Windows only, you must also add the bcrypt.lib library during the linking phase.

We support and test the following compilers: GCC, Clang, and Microsoft C++ (MSVC), but any C++ compiler should work.

Compiling C++ code can be tedious, especially when you have to compile code you didn't write yourself. That's why we've taken particular care to provide project examples for the most popular IDEs.

All the examples in our module documentation include GNU Makefile, Visual Studio, Xcode, and Code:: Blocks projects. These projects include all the files mentioned above. This allows you to familiarize yourself with our library using a known environment.

Note that if you use CMake to compile your projects, we also have a "Prog-CMake" example that shows you how to include our library in a CMake project.

Compiling the library without SSL/TLS

If you don't need to use the https:// or wss:// protocols, you can compile our library without Mbed-TLS. Simply define the NO_YSSL macro in your IDE or makefile.

In this case, all calls to Mbed-TLS are ignored and all you have to do is compile the files in the "Sources" and "Sources/yapi" sub-directories. You can ignore the entire contents of the "Sources/yapi/mbedtls" directory.

If, in your code, you try to connect to a host that requires a secure connection, such as "VirtualHub for Web", the function returns a "YAPI_NOT_SUPPORTED" error with the message "SSL support is not activated.".

Conclusion

The new version of Mbed-TLS makes compiling our library a little more complicated, but we've done our best to ease the transition for you. Whatever your environment, you should find an example in our library, but if you still can't compile the library in your IDE, don't hesitate to contact Yoctopuce support (support@yoctopuce.com).

Add a comment No comment yet Back to blog












Yoctopuce, get your stuff connected.