windows 环境 使用emcc 导出.wasm
extern “C” 大概意思是在C++ 中兼容C 或者用C 去解释/编译下面
#include <stdio.h>
#include <math.h>
int main() {
printf("hello, world \n");
return 0;
}
extern "C" {
int int_sqrt(int x) {
return sqrt(x); // math.h 中开平方的方法
}
}
cmd 中执行命令
test.cpp -s EXPORTED_FUNCTIONS="['_int_sqrt','_main']" -o test.js
为什么要记录,因为踩了坑吧
test.cpp -s EXPORTED_FUNCTIONS='["_int_sqrt", "_main"]' -o test.js
区别就在于引号的区别吧