从C++编译WebAssembly的实用指南 Set the CMAKE Toolchain export CMAKE_TOOLCHAIN_FILE=/home/user/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake Compile to WASM (default) cd build emcmake cmake ../cpp -DJS_ONLY=OFF make Compile to JS cd build emcmake cmake ../cpp -DJS_ONLY=ON make 参考资料 《Compile C++ to WebAssembly and JavaScript using Emscripten and CMake》