Nginx+FFmpeg+h265+wasm+webgl实现(1)Emscripten环境搭建以及简单的使用方法介绍

本文介绍如何使用Emscripten将C/C++代码编译成可在浏览器中运行的JavaScript和WebAssembly文件。通过详细步骤,从环境搭建到简单示例的编译,展示了Emscripten的基本用法。

(1)Emscripten环境搭建以及简单的使用方法介绍

简介:Emscripten可以把C/C++编译成.js和.wasm文件,用于浏览器使用。

①,安装Emscripten编译期

# Get the emsdk repo
git clone https://github.com/emscripten-core/emsdk.git

# Enter that directory
cd emsdk
git pull

# Download and install the latest SDK tools.

./emsdk install latest

# Make the "latest" SDK "active" for the current user. (writes .emscripten file)

./emsdk activate latest

# Activate PATH and other environment variables in the current terminal

source ./emsdk_env.sh


②,编写代码
hello.c

#include<stdio.h>



int main(){

printf(“hello world\n”);

}

 

编译:可以输出html,也k可以不进行输出。

./emcc hello.c -o hello.html

 

使用浏览器打开hello.html,结果如下,网页和控制台都能看到hello world。

 

 

参考
https://github.com/emscripten-core/emscripten
https://webassembly.org/
https://emscripten.org/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值