简体   繁体   中英

How do I use the preamble.js file in emscripten?

I'm trying to get started with a small web-application with webassembly, and I'm using emscripten. Emscripten has this "preamble.js" file that " provide programmatic access for interacting with the compiled C code ". My problem is that I don't understand how to actually use this file. It's not javascript code so my browser can't load it, and it's not C/C++ code so my compiler can't compile it. So what do I do with it?

Sorry if this is painfully obvious or documented somehwere, but I can't see it.

preamble.js by itself can't be loaded in a browser, but when you use emscripten to generate a JavaScript (or HTML) output file (eg by invoking emcc foo.c -o foo.js ), it will include a preprocessed version of the preamble along with your asm.js code in the output file. (Or if you use WebAssembly, it will also generate a foo.wasm file to go along with foo.js ). The output foo.js file should be loadable in the browser (or eg node.js if it doesn't use web APIs).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM