如何将从Webassembly创建的wasm导入Angular?

时间:2019-12-04 14:26:17

标签: c++ c angular webassembly

我正在尝试使用webassembly在Angular和im中实现c / c ++。

  1. program.c

#include <stdio.h>

int func(int n){
    return n+2;
}


int main(){
    printf("Hello world!\n");
        int res = func(5);
    printf("func(5) = %d\n", res);
    return 0;
}

执行以下命令后,将生成两个文件.js和.wasm

emcc program.c -o hello.js -s WASM = 1 -s EXTRA_EXPORTED_RUNTIME_METHODS ='[“ cwrap”]'

使用.html文件,结果很好

emcc program.c -o hello.html -s WASM = 1 python -m SimpleHTTPServer 8080

  1. Form component.html不会给出任何结果

<script async type="text/javascript" src="../hello.js"></script>
<p>Open the console to see the result!</p>

<script type='text/javascript'>
    var Module = {
      preRun: [],
      postRun: [],
      print: (function() {

        return function(text) {
        console.log("eeeeee",text);
      
        };
      })(),
  
    };

  </script>

0 个答案:

没有答案