OS: Windows 10 x64

I. install

0. pre install

Python2.7
Node js
Java

1. down

git clone https://github.com/emscripten-core/emsdk.git

注意:最新版本信息请查看“emscripten-tags.txt”

(1) lkgr.json
https://storage.googleapis.com/wasm-llvm/builds/linux/lkgr.json
to "emsdk\upstream"

(2) llvm
https://s3.amazonaws.com/mozilla-games/emscripten/packages/llvm/tag/win_64bit/emscripten-llvm-e1.38.30.zip
to "ëmsdk\zips"

2. setup

(1) custom install

emsdk install clang-e1.

(2) activate

emsdk activate --vs2013 clang-e1.

(3) test

emsdk_env

II. usage

1. compile BC file

emcc tests/hello_world.c

2. output

(1) normal

emcc tests/hello_world.c -o hello.html

(2) sdl

emcc tests/hello_world_sdl.cpp -o hello.html

(3) file

emcc tests/hello_world_file.cpp -o hello.html --preload-file tests/hello_world_file.txt

3. run

python -m SimpleHTTPServer 

http://localhost:8080/hello.html

Src:

1. hello_world.c

/*
 * Copyright 2011 The Emscripten Authors.  All rights reserved.
 * Emscripten is available under two separate licenses, the MIT license and the
 * University of Illinois/NCSA Open Source License.  Both these licenses can be
 * found in the LICENSE file.
 */

#include <stdio.h>

int main() {
  printf("hello, world!\n");
  ;
}

2. hello_world_sdl.cpp

// Copyright 2011 The Emscripten Authors.  All rights reserved.
// Emscripten is available under two separate licenses, the MIT license and the
// University of Illinois/NCSA Open Source License.  Both these licenses can be
// found in the LICENSE file.

#include <stdio.h>
#include <SDL/SDL.h>

#ifdef __EMSCRIPTEN__
#include <emscripten.h>
#endif

extern "C" int main(int argc, char** argv) {
  printf("hello, world!\n");

  SDL_Init(SDL_INIT_VIDEO);
  SDL_Surface *screen = SDL_SetVideoMode(, , , SDL_SWSURFACE);

#ifdef TEST_SDL_LOCK_OPTS
  EM_ASM("SDL.defaults.copyOnLock = false; SDL.defaults.discardOnLock = true; SDL.defaults.opaqueFrontBuffer = false;");
#endif

  if (SDL_MUSTLOCK(screen)) SDL_LockSurface(screen);
  ; i < ; i++) {
    ; j < ; j++) {
#ifdef TEST_SDL_LOCK_OPTS
      // Alpha behaves like in the browser, so write proper opaque pixels.
      ;
#else
      // To emulate native behavior with blitting to screen, alpha component is ignored. Test that it is so by outputting
      // data (and testing that it does get discarded)
      ;
#endif
      *((Uint32*)screen->pixels + i *  + j) = SDL_MapRGBA(screen->format, i, j, -i, alpha);
    }
  }
  if (SDL_MUSTLOCK(screen)) SDL_UnlockSurface(screen);
  SDL_Flip(screen); 

  printf("you should see a smoothly-colored square - no sharp lines but the square borders!\n");
  printf("and here is some text that should be HTML-friendly: amp: |&| double-quote: |\"| quote: |'| less-than, greater-than, html-like tags: |<cheez></cheez>|\nanother line.\n");

  SDL_Quit();

  ;
}

3. hello_world_file.cpp

// Copyright 2012 The Emscripten Authors.  All rights reserved.
// Emscripten is available under two separate licenses, the MIT license and the
// University of Illinois/NCSA Open Source License.  Both these licenses can be
// found in the LICENSE file.

#include <stdio.h>
int main() {
  FILE *file = fopen("tests/hello_world_file.txt", "rb");
  if (!file) {
    printf("cannot open file\n");
    ;
  }
  while (!feof(file)) {
    char c = fgetc(file);
    if (c != EOF) {
      putchar(c);
    }
  }
  fclose (file);
  ;
}

hello_world_file.txt

==
This data has been read from a file.
The file is readable as if it were at the same location in the filesystem, including directories, as in the local filesystem where you compiled the source.
==

Reference:

1. Emscripten SDK

2. emscripten tutorial

Emscripten 安装和使用的更多相关文章

  1. WebAssembly完全入门——了解wasm的前世今身

    前言 接触WebAssembly之后,在google上看了很多资料.感觉对WebAssembly的使用.介绍.意义都说的比较模糊和笼统.感觉看了之后收获没有达到预期,要么是文章中的例子自己去实操不能成 ...

  2. WebAssembly 上手

    安装 Mac 上最便捷的安装方式当然是通过 Homebrew: $ brew install emscripten 安装好之后讲道理就已经自动配置好一切,然后 emcc 命令便可用了. 下面看非 Ho ...

  3. Ubuntu 18.04 下 emscripten SDK 的安装

    Ubuntu 18.04 下 emscripten SDK 的安装http://kripken.github.io/emscripten-site/docs/getting_started/downl ...

  4. windows下安装emscripten

    windows下安装emscripten windows下安装emscripten需要python.git环境 python安装 git安装 开始安装 # 1.克隆emsdk git clone ht ...

  5. Web字节码(WebAssembly) Emscripten编译器安装

    首先你需要提前安装 git python 环境并且Ctrl+R输入cmd在windows的dos界面下能够运行 第一步: 在github上downloade下来emsdk git clone http ...

  6. VS2010 c/c++ 本地化 emscripten 配置

    配置环境 1.下载emsdk-1.35.0-full-64bit.exe,有VS2010的话直接安装. 2.安装好之后,打开cmd,# emsdk update # emsdk install lat ...

  7. emscripten、 WebAssembly,传递字符串给c函数

    下面看具体的实例. 下面的代码是一个C函数,实现简单的字符串拼接,然后返回拼接的字符串. #include <stdio.h> #include <string>  char* ...

  8. Mac环境 安装brew

    一.brew官网主页上的方法: /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/insta ...

  9. mingw 搭建Emscripten 环境

    mingw 环境的搭建可以参考网上很多文章,不复杂.但在搭建Emscripten 环境之前需要配置git 和python 和MSbuild.exe 还需要安装camke 默认安装之后应该是添加了 系统 ...

随机推荐

  1. python安装requests

    下面是requests的安装步骤: 1.如果系统已经装了Python,把D:\python3.6.5\Scripts添加到系统的环境变量PATH后面 2.cmd下cd到这个目录下D:\Python3. ...

  2. Python第一个GUI

    #!/usr/bin/python#coding=utf-8'''Created on 2017年11月2日 from home @author: James zhan ''' from functo ...

  3. day060 ajax文件上传 json补充

    请求头ContentType 文件上传时需要指定请求头,常见的类型有3种: 1.application/x-www-form-urlencoded(可以类比成在url后面拼接的形式发送,即a=1&am ...

  4. weinre 远程调试 安装 配置

    1.第一种方法:安装:npm install -g weinre 2.第一种方法:开启本地监听服务器(修改端口,默认端口是8080):在cmd中运行: weinre --httpPort 8101 - ...

  5. python魔术方法(__init__,__call__,被双下划线包围的方法)

    转载link:http://pycoders-weekly-chinese.readthedocs.io/en/latest/issue6/a-guide-to-pythons-magic-metho ...

  6. 使用GraphHttpClient调用Microsoft Graph接口 - POST

    博客地址:http://blog.csdn.net/FoxDave 本篇接上一讲,我们继续看如何通过GraphHttpClient创建一个Office 365的组,需要使用POST请求. 为结果添加按 ...

  7. vue 关闭浏览器

    在开发中的一个需求,vue中关闭浏览器, 直接使用window.close()在chrome.fireFox会不起作用 需要改为一下方式 window.open('about:blank','_sel ...

  8. Django-----加入MD5格式上传图片

    上传图片为什么要加 MD5 ? 答 :避免用户上传图片的时候图片名重复,而引起先上传的图片被后上传的图片所覆盖的失误! MD5是什么? 答:一种被广泛使用的密码散列函数,可以产生出一个128位(16字 ...

  9. Makefile 中 -rpath -rpath-link

    -rpath和-rpath-link 假设有3个文件,在同一目录下,有这样的依赖关系 test->liba.so->libd.so 如果编译test的时候这样写 gcc test.c –l ...

  10. WEBBASE篇: 第七篇, JavaScript知识1

    JavaScript 1 一.JavaScript 概述什么是JavaScript: JavaScript 简称 JS,是一种专门运行于JS解释器/引擎中的解释型脚本语言JS发展史: 1.1992年N ...