emsdk 开发环境搭建
https://emscripten.org/docs/getting_started/Tutorial.html
安装cmake
sudo apt install cmake -y
sudo apt install gcc g++ -y
sudo apt-get install default-jre -y
git clone https://github.com/juj/emsdk.git --depth=1
cd emsdk
git pull
./emsdk install latest
./emsdk activate latest
source ./emsdk_env.sh
./emsdk install sdk-incoming-64bit binaryen-master-64bit
./emsdk activate sdk-incoming-64bit binaryen-master-64bit
添加环境变量
c
#include <stdio.h>
int main() {
printf("hello, world!
");
return 0;
}
./emcc tests/hello_world.c
node a.out.js
./emcc tests/hello_world.c -o hello.html