Skip to content

All c/c++ programs can be compiled to Wasm without any xmake.lua configuration changes, just switch to the wasm compilation platform and compile.

sh
$ xmake f -p wasm
$ xmake

For detailed wasm compilation configuration see: wasm configuration

Alternatively, when compiling a file with the -preload-file assets/xxx.md setting, we can also simplify its setup by configuring

EXPLORER
src
assets
file1.txt
file2.txt
main.cpp
xmake.lua
Lua xmake.lua
1234567
add_rules("mode.debug", "mode.release")

target("test")
    set_kind("binary")
    add_files("src/*.cpp")
    add_values("wasm.preloadfiles", "src/assets/file1.txt")
    add_values("wasm.preloadfiles", "src/assets/file2.txt")