{"id":21457895,"url":"https://github.com/nathanpotter17/emcc-wasm","last_synced_at":"2025-04-22T14:11:26.813Z","repository":{"id":260967570,"uuid":"867365831","full_name":"nathanpotter17/emcc-wasm","owner":"nathanpotter17","description":"WebAssembly and WASI using C++ \u0026 Rust","archived":false,"fork":false,"pushed_at":"2025-04-07T16:16:05.000Z","size":92842,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-07T17:29:10.845Z","etag":null,"topics":["c","cpp","emscripten","js","wasm","wasmtime","webassembly"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nathanpotter17.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-03T23:37:10.000Z","updated_at":"2025-04-07T16:16:08.000Z","dependencies_parsed_at":"2025-03-26T16:41:44.378Z","dependency_job_id":null,"html_url":"https://github.com/nathanpotter17/emcc-wasm","commit_stats":null,"previous_names":["nathanpotter17/emcc-wasm"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nathanpotter17%2Femcc-wasm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nathanpotter17%2Femcc-wasm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nathanpotter17%2Femcc-wasm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nathanpotter17%2Femcc-wasm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nathanpotter17","download_url":"https://codeload.github.com/nathanpotter17/emcc-wasm/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250255700,"owners_count":21400410,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c","cpp","emscripten","js","wasm","wasmtime","webassembly"],"created_at":"2024-11-23T06:16:09.419Z","updated_at":"2025-04-22T14:11:21.806Z","avatar_url":"https://github.com/nathanpotter17.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Emscripten Build System for WASM Based Applications\n\n## Install Emscripten Core SDK\n\nIn your shell of choice, navigate to the emsdk directory and run the following commands:\n\n`git clone https://github.com/emscripten-core/emsdk.git`\n\n`./emsdk install latest`\n\n`./emsdk install activate` || `./emsdk install activate --permanent`\n\nRun `./emsdk help` for more information.\n\nSee https://emscripten.org/docs/tools_reference/emsdk.html#command-line-syntax for full emsdk command list.\n\n## Start Building or Running Examples\n\nMac / Linux / Windows: `bash build.sh`\n\nRun using VSCode's Live Server or any other server, to serve the HTML file at the root. It contains all examples served from the build folder.\n\nNote: If you are using Windows, using Wasmtime to run files requires .msi installation from https://github.com/bytecodealliance/wasmtime/releases.\n\nNote: If you are using Windows, wat2wasm requires the WABT package from https://github.com/WebAssembly/wabt/releases and then ran via cmd. Ensure all path variables are set correctly.\n\nMac / Linux: `curl https://wasmtime.dev/install.sh -sSf | bash`\n\nOtherwise, follow this guide: https://docs.wasmtime.dev/introduction.html for the most up-to-date usage of WASI.\n\n## Get Started with Emscripten Compiler\n\nEmscripten is a compiler that allows you to compile multi-lingual code to WebAssembly Binary by being tightly coupled with LLVM, Clang, Binaryen, and Closure Compiler.\n\n`emcc hello.c -o out.js`\n\n`node out.js`\n\nSee https://emscripten.org/docs/getting_started/Tutorial.html#running-emscripten for more detail.\n\n## Advanced Usage - Build Libraries for use in seperate files\n\n![img](src/library/wasm-track.png)\n\n[PDF](src/library/dlibemcc.pdf)\n\nSee `src/library/cmake` for examples on compiling and including libraries.\n\n## Build HTML - embedded only, no direct access to modules.\n\n`\"buildHTML\": \"emcc src/gol.cpp -o build/gol.html\"`\n\nSee `build/gol.html` for example.\n\nNote: It is recommended to pass optimization flags (O1-O3) and MINIFY_HTML=1 to reduce the size of the output.\n\n`\"buildHTML\": \"emcc src/gol.cpp -o build/gol.html -O3 -s MINIFY_HTML=1\"`\n\n## Build JS - embeddable, access module via Module.isRuntimeInitialized\n\nSee `build/gol.js` for example - https://webassembly.github.io/spec/js-api/#sample\n\n`\"buildAccessor\": \"emcc -o build/gol.js src/gol.cpp -s EXPORTED_RUNTIME_METHODS=['ccall'] -s EXPORTED_FUNCTIONS=\\_main,\\_myFunction\"`\n\n## Build WASM - standalone \u0026 embeddable.\n\nMore information about building WASM standalone using emcc, in relation to V8 - https://v8.dev/blog/emscripten-standalone-wasm\n\nUse wasm-dis or wasm2wat to view the binaries in text format. https://github.com/WebAssembly/binaryen/blob/main/src/tools/wasm-dis.cpp\n\n`\"buildWASM\": \"emcc src/gol.cpp -o build/gol.wasm -s STANDALONE_WASM=1 -s EXPORTED_FUNCTIONS=[_main,_myFunction]\"`\n\n`\"buildSimple\": \"emcc src/c/simple.c -o build/simple.wasm -s STANDALONE_WASM=1 -s EXPORT_ALL=1\"`\n\n`\"buildWAT\": \"wat2wasm src/wasm/memory.wat -o build/memory.wasm\"`\n\n## Example Vector Math C-\u003eJS Library\n\nSee `/src/js/*.js` for examples.\n\n`\"buildVec\": \"emcc src/c/vectors.c -o build/vectors.wasm -s STANDALONE_WASM=1 -s EXPORTED_FUNCTIONS=_alloc_vector,_dealloc_vector,_add_vectors,_sub_vectors,_mul_scalar\"`\n\n## Build ASC - AssemblyScript - A TS Variant for WASM\n\nA TypeScript-like language for WebAssembly.\n\nhttps://www.assemblyscript.org/ uses https://github.com/WebAssembly/binaryen under the hood.\n\n`\"buildASC\": \"asc src/ts-asc/fib.ts --outFile build/assembly.wasm --optimize\"`\n\n## Run Standalone WASM - Wasmer or WasmTime - WASI (WebAssembly System Interface)\n\nSee the `src/wasi` directory for more information on WASI.\n\n## Build from WAT Only - wat2wasm - WebAssembly Text Format\n\nUse wat2wasm to convert wat text file to wasm binaries. https://github.com/webassembly/wabt / https://github.com/xtuc/webassemblyjs/tree/master/packages/wast-loader\n\n`\"buildWASMOnly\": \"wat2wasm src/simple.wat -o build/simple.wasm\"`\n\nTo see more examples, visit https://github.com/emscripten-core/emscripten/wiki/Porting-Examples-and-Demos\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnathanpotter17%2Femcc-wasm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnathanpotter17%2Femcc-wasm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnathanpotter17%2Femcc-wasm/lists"}