WebAssembly 安装

卸载预装的“open-vm-tools”包

检测是否预装了 open-vm-tools

yum list installed | grep open-vm-*

卸载预装的程序包

yum remove open-vm-tools

#再次确认是否卸载成功

rpm -qa | grep open-vm-*

重启

reboot

安装 VMware Tools

 ./vmware-install.pl

 

Centos7.6安装glibc2.18

cd /home/install

wget http://ftp.gnu.org/gnu/libc/glibc-2.18.tar.gz

tar xvf glibc-2.18.tar.gz

cd glibc-2.18

mkdir build

cd build

../configure --prefix=/usr --disable-profile --enable-add-ons --with-headers=/usr/include --with-binutils=/usr/bin

make -j4

make install

ldd --version

 

Centos7安装NPM

Posted on 2019-12-26 15:01  Shapley  阅读(12147)  评论(0)  编辑  收藏

1.安装gcc

yum install gcc gcc-c++

2.下载node国内镜像(推荐)

wget https://npm.taobao.org/mirrors/node/v10.14.1/node-v10.14.1-linux-x64.tar.gz

3.解压并重命名文件夹

tar -xvf  node-v10.14.1-linux-x64.tar.gz
mv node-v10.14.1-linux-x64 node

4.添加环境变量

vi /etc/profile

在文件最后添加以下配置:

export NODE_HOME=/usr/local/node  
export PATH=$NODE_HOME/bin:$PATH

5.刷新配置

source /etc/profile

6.验证结果:

node -v

npm -v

https://emscripten.org/docs/getting_started/downloads.html

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

# Enter that directory
cd emsdk

https://github.com/sonysuqin/WasmVideoPlayer

# Fetch the latest version of the emsdk (not needed the first time you clone)
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

On Windows, run emsdk instead of ./emsdk, and emsdk_env.bat instead of source ./emsdk_env.sh.

yum install npm

sudo apt-get install python3

# Install CMake (optional, only needed for tests and building Binaryen)
sudo apt-get install cmake

# Install Java (optional, only needed for Closure Compiler minification)
sudo apt-get install default-jre

 

4、安装,注意这一步比较容易出问题,请保持耐心。对这一步,建议新手先看完整,再进行实践。

在cmd中运行emsdk.bat install latest

经验证,这一步一般进行不下去,自动下载安装期间几乎百分百出错:

Error: Downloading URL '…node-v12.9.1-win-x64.zip…': <urlopen error [Errno 10060] >

Installation failed!

 

解决办法:

根据提示,将上网搜索下载需要的.zip文件,放入emsdk目录中的zips目录

再次运行emsdk.bat install latest

我在测试时发现,在git bush中运行emsdk.py install latest,比在cmd中运行emsdk.bat install latest,建议使用git bush,下面演示就是用它。

 

 

 

 

编译并运行一个简单的程序

现在,我们已经有了一个完整的工具链,将简单的程序编译成 WebAssembly。不过,这里有一些值得提醒的地方:

  • 在使用 emcc 命令时,要带着 -s WASM=1 参数(不然,默认将会编译成asm.js)。
  • 如果我们想让 Emscripten 生成一个我们所写程序的HTML页面,并带有 wasm 和 JavaScript 文件,我们需要给输出的文件名加 .html 后缀名。
  • 最后,当我们运行程序的时候,我们不能直接在浏览器中打开 HTML 文件,因为跨域请求是不支持 file 协议的。我们需要将我们的输出文件运行在HTTP协议上。

下面这些命令可能让你创建一个简单的“hello word”程序,并且编译它。

mkdir hello
cd hello
echo '#include <stdio.h>' > hello.c
echo 'int main(int argc, char ** argv) {' >> hello.c
echo 'printf("Hello, world!\n");' >> hello.c
echo '}' >> hello.c
emcc hello.c -s WASM=1 -o hello.html

我们可以使用 emrun 命令来创建一个 http 协议的 web server 来展示我们编译后的文件。

$ emrun --no_browser --port 8080 .
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值