Compile C/C++ to Wasm WASI
Last updated
Was this helpful?
Last updated
Was this helpful?
Now that you have , let's get our hands dirty!
Wasienv comes with C/C++ support preinstalled, so you just need to run one command to get things running ๐
If you want to compile a simple C example, you can just create the following:
Now that you have this file created, you can execute wasicc
Et voilรก... you will have a new file example.wasm
ready to be executed with your favorite WebAssembly runtime!
Wasienv also allows you to compile C++ files to Wasm WASI, just run it with wasic++
In some projects, there might be already ./configure
files that will configure the system (creating a Makefile normally) to compile a certain project.
If you want to use Wasienv there, you just need to wrap your ./configure
call with wasiconfigure
!
Wasienv also has a wrapper for Makefiles
Similarly to configure and make, we also have another command that will automatically compile all your projects made with CMake
You can also execute the example.wasm
file in your browser or in Node.js using . Check out the examples on how to do it!
Here's an that was compiled to WebAssembly WASI thanks to Wasienv!
And the for generating the wasm file: