{"id":25227,"library":"emscripten-library-generator","title":"Emscripten Library Generator","description":"The emscripten-library-generator (v0.3.0) converts normal JavaScript libraries into Emscripten's custom JS library format (.js) for use with the --js-library flag. It also auto-generates EXPORTED_FUNCTIONS lists via the --unresolved flag. Created by Emscripten author Evan Wallace, it resolves dependencies and prefixes symbols with underscores to match Emscripten's ABI. Development appears complete as of 2015; no recent releases. Unlike manual library authoring, it automates dependency resolution and underscore prefixing.","status":"maintenance","version":"0.3.0","language":"javascript","source_language":"en","source_url":"https://github.com/evanw/emscripten-library-generator","tags":["javascript"],"install":[{"cmd":"npm install emscripten-library-generator","lang":"bash","label":"npm"},{"cmd":"yarn add emscripten-library-generator","lang":"bash","label":"yarn"},{"cmd":"pnpm add emscripten-library-generator","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This is a CLI tool, not a library. Install globally and run via emscripten-library-generator.","symbol":"CLI tool","correct":"npm install -g emscripten-library-generator"}],"quickstart":{"code":"npm install -g emscripten-library-generator\necho 'var counter = 0;\nfunction increment() {\n  counter++;\n  return counter;\n}\nfunction increment_double() {\n  increment();\n  return counter * 2;\n}' > input.js\nemscripten-library-generator input.js > library.js\ncat library.js","lang":"javascript","description":"Shows installation and generation of an Emscripten library from a simple JS file with dependencies."},"warnings":[{"fix":"Put initialization code into a JavaScript function called as the first statement inside main() in C++.","message":"Top-level statements other than variable or function declarations are not supported.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"In C++ code, use the underscore-prefixed names (e.g., _Foo_new) or use EXPORTED_FUNCTIONS with underscores.","message":"All global symbols are automatically prefixed with an underscore to match Emscripten's output.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use only ES5 syntax in input files.","message":"The tool may not work with modern JavaScript features (ES6+).","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run 'npm install -g emscripten-library-generator' and ensure npm global binaries are in PATH.","cause":"The tool is not installed globally or not in PATH.","error":"sh: emscripten-library-generator: command not found"},{"fix":"Install acorn: 'npm install -g acorn' or install emscripten-library-generator locally and run via npx.","cause":"Missing dependency; old version of emscripten-library-generator may require acorn.","error":"Error: Cannot find module 'acorn'"},{"fix":"Rewrite input files in ES5 syntax (no arrow functions, const/let, etc.).","cause":"Input JavaScript uses ES6+ syntax not supported by the parser.","error":"SyntaxError: Unexpected token ..."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}