title: LinkError when trying Hello World in Rust with WebAssembly
body: <p>I'm trying to run a hello world program made in Rust with WebAssembly, but I'm getting an error message when I try to load the program. </p>
  
  <p>I was able to get it running when following some tutorials that I found, the problem is that they use Emscripten to create JavaScript and HTML for loading the code, but this JavaScript and HTML includes tons and tons of boilerplate and other stuff. I got kinda lost and instead wanted to try to get a really simple example that I'm loading myself.</p>
  
  <p>I ran the following to compile hello.wasm</p>
  
  <pre class="lang-none prettyprint-override"><code>echo 'fn main() { println!("Hello, Emscripten!"); }' &gt; hello.rs
  rustc --target=wasm32-unknown-emscripten hello.rs
  </code></pre>
  
  <p>To load hello.wasm, I took the example from the Mozilla WebAssembly docs and tried to run that.</p>
  
  <pre><code>var importObject = {
    imports: {
      imported_func: function(arg) {
        console.log(arg);
      }
    }
  };
  
  fetch('hello.wasm').then(response =&gt;
    response.arrayBuffer()
  ).then(bytes =&gt;
    WebAssembly.instantiate(bytes, importObject)
  ).then(results =&gt; {
    // Do something with the compiled results!
  });
  </code></pre>
  
  <p><code>WebAssembly.instantiate</code> crashes:</p>
  
  <pre class="lang-none prettyprint-override"><code>LinkError: Import #0 module="env" error: module is not an object or function
  </code></pre>
  
  <p>I found something about this error having to do with something missing, that the boilerplate code is supposed to load, but looking through the autogenerated HTML and JavaScript I couldn't figure out exactly what it could be.</p>