GettingEmscriptenToWork.wiki
changeset 221 9b7f99b498a5
parent 220 122b02f4f292
child 222 bce10fea1e6e
equal deleted inserted replaced
220:122b02f4f292 221:9b7f99b498a5
     1 #summary One-sentence summary of this page.
     1 #summary One-sentence summary of this page.
       
     2 #labels emscripten
     2 
     3 
     3 This page is a brief introduction of how to get emscripten to work.
     4 This page is a brief introduction of how to get emscripten to work.
     4 
     5 
     5 = Introduction =
     6 = Introduction =
     6 
     7 
    41 
    42 
    42 Here I just give some simple examples.
    43 Here I just give some simple examples.
    43 
    44 
    44 (Assume that you are in the emscripten root directory, where you can see the 'emcc' file)
    45 (Assume that you are in the emscripten root directory, where you can see the 'emcc' file)
    45 
    46 
    46 1. *hello world*
    47 1. *Hello World*
    47 
    48 
       
    49 {{{
    48 ./emcc tests/hello_world.cpp
    50 ./emcc tests/hello_world.cpp
    49 node a.out.js
    51 node a.out.js
       
    52 }}}
    50 
    53 
    51 You should be able to see "hello world!" in the terminal
    54 You should be able to see "hello world!" in the terminal
    52 
    55 
    53 If you want to have it run in browsers, you can type this (as in official tutorial):
    56 If you want to have it run in browsers, you can type this (as in official tutorial):
    54 ./emcc tests/hello_world_sdl.cpp -o hello.html
    57 {{{
       
    58 ./emcc tests/hello_world.cpp -o hello.html
       
    59 }}}
    55 
    60 
    56 2. *get the glgears to work in browsers*
    61 2. *Get the glgears to work in browsers*
       
    62 {{{
       
    63 ./emcc tests/hello_world_gles.c -o hello_world_gles.html
       
    64 }}}
    57 
    65 
    58 ./emcc tests/hello_world_gles.c -o hello_world_gles.html
    66 llvm 3.2+ won't compile this demo. The reason is that this demo uses malloc which has to been compiled first from dlmalloc. However emscripten uses llvm-ld as the linker, which has been removed in llvm 3.2+, and the result is that you will encounter some strange error messages saying that "no such file or directory". If you get this message, check your llvm and clang version.
    59 
    67 
    60 llvm 3.1+ won't compile this demo. The reason is that this demo uses malloc which has to been compiled first from dlmalloc. However emscripten uses llvm-ld as the linker, which has been removed in llvm 3.1+, and the result is that you will encounter some strange error messages saying that "no such file or directory". If you got this message, check your llvm and clang version.
    68 3. *Get the file system to work*
    61 
    69 
    62 3. *get the file system to work*
    70 {{{
    63 
       
    64 ./emcc --preload-file hello_world_file.txt tests/hello_world_file.c -o hello_world_file.html
    71 ./emcc --preload-file hello_world_file.txt tests/hello_world_file.c -o hello_world_file.html
       
    72 }}}
    65 
    73 
    66 Note that you must add "--preload-file hello_world_file.txt" in the command line. This line tells emcc that it should embed the file loading code into the js file. Before the application runs, all files will be loaded first. If you don't do this, it won't find this file.
    74 Note that you must add "--preload-file hello_world_file.txt" in the command line. This line tells emcc that it should embed the file loading code into the js file. Before the application runs, all files will be loaded first. If you don't do this, it won't find this file.