C++ SDK or API - looking for collaborators

Hi all,

I recently succeeded in compiling & deploying a C++ application that includes the standard library AND an external library, the nlohmann/json library.

For this, I am using a patched wasi-sdk compiler, which provides the clang++ compiler and the standard library, plus a home-grown IC API to get messages in/out via Candid.

The patched wasi-sdk is already open source, you can find it here.

But the IC-API, which I call icpp is not yet. It needs a bit more work. I had applied for a small grant to open source that IC API, because I think it can be a good starting point for full fledged C++ support.

My icpp API was reviewed by @roman-kashitsyn, and his feedback was that my approach is not ideal/not scalable, and he proposed an alternative approach to build a C++ SDK instead of an API.

I like to explore both approaches together with others that are interested in this topic, and potentially team up to apply for a grant together.

@domwoe already confirmed that funding would be available and a #cplusplus discord channel was opened.

Hope to see some of you there!


Hi all,

After many months of work, the first development release, icpp 0.1.0, is now available.

You can find it here.

Look forward to your feedback.


Good to see this. Cheers.

1 Like

Super cool @icpp! This also allows compiling many C++ libraries to be usable in the IC, right?

1 Like

Hi @domwoe ,
yes it indeed allows you to compile any C++ library to be usable in the IC, as long as

  • It is not using something unsupported by WebAssembly, like Exceptions.
  • It is not generating more than 300 Globals, because that is the current limit on the IC

Two examples I am using already:

  • ZipIterator:

    • Used inside icpp itself, when deserializing a Record, to sort multiple vectors based on field hash
    • I only had to out-comment usage of sstream, to avoid going over the max Globals
  • nlohmann/json:

    • I use it in our QA canister, to demonstrate how CandidTypeText can be used to send JSON back & forth over the wire
    • I only had to specify one compile flag available in the nlohmann/json library so it builds for environments without a file system. It compiled, linked and ran on the IC without any modifications:
      • cpp_compile_flags = [“-D JSON_HAS_FILESYSTEM=0”]

More and more C++ libraries can be compiled to WebAssembly, and with little effort it is then possible to use them on the IC, as long as the max Globals is not exceeded.