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.
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.