728x90
Emscripten은 C/C++ 코드와 같은 네이티브 프로그램을 웹에서 실행할 수 있는
자바스크립트로 변환해 주는 오픈 소스 컴파일러.
Emscripten은 WebAssembly(Wasm) 또는 자바스크립트(JavaScript)로 컴파일된 코드가 웹 브라우저에서 실행되도록 해주고 이를 통해 기존의 네이티브 프로그램을 웹 환경으로 손쉽게 포팅 할 수 있다.
Docker image로 emsdk 설치하기
Debian 배포판 터미널에서 작업한다.(Linux)
1. docker 설치(선택)
sudo apt install docker.io
2. docker pull 명령으로 emsdk(최신버전) 설치
docker pull emscripten/emsdk:latest
3. docker images 명령으로 emsdk 설치 확인
docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
emscripten/emsdk latest 8fb101a55d06 9 days ago 1.96GB
4. 간단한 사용 예)
helloworld.cpp 파일 생성
# create helloworld.cpp
cat << EOF > helloworld.cpp
#include <iostream>
int main() {
std::cout << "Hello World!" << std::endl;
return 0;
}
EOF
docker image로 helloworld.cpp 컴파일
( helloworld.html 생성)
# compile with docker image
docker run \
--rm \
-v $(pwd):/src \
-u $(id -u):$(id -g) \
emscripten/emsdk \
emcc helloworld.cpp -o helloworld.html
Python에서 간단한 HTTP 서버 실행하기
python -m http.server 8080
http://localhost:8080/helloworld.html

자세한 내용
https://hub.docker.com/r/emscripten/emsdk
hub.docker.com
반응형
'web' 카테고리의 다른 글
Emscripten Embind(C++ 함수를 JavaScript에 바인딩) 사용해 보기 (1) | 2024.11.19 |
---|---|
React Creating a New Application (0) | 2024.11.18 |
React 시작하기 (0) | 2024.11.17 |
티스토리 블로그를 검색 사이트(네이버, 구글)에 등록하기 (0) | 2021.05.28 |
웹 프로그래밍 튜토리얼 (0) | 2021.05.01 |