ETC

[WASM] WSL-Ubuntu에 emscripten 설치

ddochea 2021. 11. 15. 00:27
반응형

emsscripten 은 c, c++로 작성한 소스코드를 최신 web browser에서 사용할 수 있는 wasm 형식으로 build/porting 해주는 도구이다. 해당 사이트에 접속하면 설치 방법 및 튜토리얼이 있는데 막히는 점이 있어 정리할 겸 작성한다.

아래 방법은 Windows WSL - Ubuntu 20.04를 기준으로 진행하였다.

 

1. emsdk 다운로드

git 명령어로 emsdk 소스를 다운로드 받은 후 해당 경로로 이동한다. WSL - Ubuntu 20.04의 경우 git 명령어가 기본 설치되어 있다. 만약 없을 경우 설치하기 바란다.

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

# Enter that directory
cd emsdk

 

2. emcc 설치

1단계를 마쳤다면 아래 명령어를 순서대로 실행한다. `./emsdk install latest`와 `./emsdk activate latest` 명령 부분에서 생각보다 시간이 오래걸린다. 혹시 잘못되었다고 생각하고 종료하지 않길 바란다.

# 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

 

3. clang 설치

WSL - Ubuntu 20.04 기준 clang이 설치되어 있지 않다. 설치를 위해 아래와 같이 명령어를 실행해줘야 한다. 

# apt repository 를 업데이트한다. 안할 경우 clang 설치에 실패한다.
sudo apt update

sudo apt install clang

 

4. 테스트

emcc -v 명령어로 설치에 이상이 없는지 확인한다.

 

출처 : Download and install — Emscripten 2.0.33-git (dev) documentation

반응형