一起幫忙解決難題,拯救IT 人的一天 | WebAssembly C
大家好,相信各位對於webassembly已經有一些基礎的認知了今天就來不免俗的就來做一下官網的Helloworld。另外筆者的開發環境是MacOS如果其他系統要安裝請參考這邊[1]。下載編譯工具cloneemsdkgit專案$gitclonehttps://github.com/emscripten-core/emsdk.git安裝sdk$cdemsdk$./emsdkinstalllatest$./emsdkactivatelatest這邊稍為講一下emsdk先引一段官網的說明Emscriptenisatoolchainforcompilingtoasm.jsandWebAssembly,builtusingLLVM,thatletsyourunCandC++onthewebatnear-nativespeedwithoutplugins.簡單來說所以就是把C/C++編譯成a...
大家好,相信各位對於 webassembly 已經有一些基礎的認知了今天就來不免俗的就來做一下官網的 Hello world。
另外筆者的開發環境是 Mac OS 如果其他系統要安裝請參考這邊[1]。
下載編譯工具clone emsdk git 專案
$ git clone https://github.com/emscripten-core/emsdk.git安裝 sdk
$ cd emsdk $ ./emsdk install latest $ ./emsdk activate latest這邊稍為講一下 emsdk 先引一段官網的說明
Emscripten is a toolchain for compiling to asm.js and WebAssembly, built using LLVM, that lets you run C and C++ on the web at near-native speed without plugins.
簡單來說所以就是把 C/C++ 編譯成 asm.js 以及 WebAssembly 的工具集。
環境變數設定 $ source ./emsdk_env.sh --build=ReleaseNote: 這邊的環境變數在 terminal 重啟之後便會失效,若想要永久的設定請添加至 .bashrc 或 .zshrc
例如添加變數至 .zshrc
# emsdk export PATH=/Users/liyanxin/Life/myprojects/emsdk:$PATH export PATH=/Users/liyanxin/Life/myprojects/emsdk/fastcomp/emscripten:$PATH export PATH=/Users/liyanxin/Life/myprojects/emsdk/node/12.9.1_64bit/bin:$PATH 編譯並且執行新增專案資料夾
$ mkdir hello &a...