简体   繁体   English

如何在emscripten中使用preamble.js文件?

[英]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. 我正在尝试使用带有webassembly的小型Web应用程序,并且正在使用emscripten。 Emscripten has this "preamble.js" file that " provide programmatic access for interacting with the compiled C code ". Emscripten具有此“ preamble.js”文件 ,该文件提供用于与已编译的C代码进行交互的程序访问 ”。 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. 它不是javascript代码,所以我的浏览器无法加载它,也不是C / C ++代码,因此我的编译器无法编译它。 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. preamble.js本身无法加载到浏览器中,但是当您使用emscripten生成JavaScript(或HTML)输出文件(例如,通过调用emcc foo.c -o foo.js )时,它将包含预处理版本序言以及输出文件中的asm.js代码。 (Or if you use WebAssembly, it will also generate a foo.wasm file to go along with foo.js ). (或者,如果您使用WebAssembly,它还将生成一个foo.wasm文件和foo.js一起使用)。 The output foo.js file should be loadable in the browser (or eg node.js if it doesn't use web APIs). 输出的foo.js文件应可在浏览器中加载(如果不使用Web API,则应加载例如node.js)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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