WASM 예제 실행하기

Park Sejin·2023년 3월 11일
post-thumbnail
  1. git clone https://github.com/emscripten-core/emsdk.git

  2. cd emsdk

  3. ./emsdk install latest

  4. ./emsdk activate latest

  5. source ./emsdk_env.sh

  6. 예제 작성

#include <iostream>

int main() {
	std::cout << "[WASM] Loaded" << std::endl;
    std::cout << "Hello World" << std::endl;
}
  1. em++ main.cpp -o index.html

  2. http-server .

    • 생성된 index.html 파일을 실행 직접 실행하면 아래와 같은 에러가 발생한다.
    • 따라서 http-server를 설치하고 서버를 통해 실행하자.

Access to XMLHttpRequest at 'file:///goinfre/sejpark/wasm_prac/index.wasm' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, isolated-app, chrome-extension, chrome, https, chrome-untrusted.

출처:

0개의 댓글