emcc hello.c -o hello.wasm
This generates a single self-contained .wasm file that's runnable as 'WASI executable': wasmtime hello
Hello World!
Some advice for C/C++ library design to make life easier for users in such 'esoteric environments':- distribute as source code, ideally as a small number of .h and .c files
- ideally don't distribute any build system files, instead make the library configurable via a handful of preprocessor defines, list those defines in the readme
- don't have builtin IO calls such as fopen/fread/fclose, instead let the library user provide any data to be processed in memory
- don't have built-in multithreading calls, instead provide functions which allow processing data in slices, so that the library user can easily call those 'slice functions' from multiple threads (or a similar solution to prevent multithreading from being baked into the library)
- ideally let the user also override memory allocation functions