Skip to content

Instantly share code, notes, and snippets.

@kyorohiro
Created December 30, 2017 05:20
Show Gist options
  • Save kyorohiro/c1443c6201adf68d37db68a6f6194bbe to your computer and use it in GitHub Desktop.
Save kyorohiro/c1443c6201adf68d37db68a6f6194bbe to your computer and use it in GitHub Desktop.
$ emcc libsqrt.c -o libsqrt.html -s EXPORTED_FUNCTIONS='["_int_sqrt"]' -s EXTRA_EXPORTED_RUNTIME_METHODS='["ccall", "cwrap"]'
$ emacs main.html
<html>
<head>
<title>Test</title>
</head>
<body>
<script src="libsqrt.js"></script>
<div id="test"></div>
<script>
int_sqrt = Module.cwrap('int_sqrt', 'number', ['number'])
elem = document.getElementById("test");
test.innerText = "#12:"+int_sqrt(12);
</script>
</body>
</html>
$ python -m SimpleHTTPServer
Serving HTTP on 0.0.0.0 port 8000 ...
Ctr-z
$ jobs -l
[1]+ 6425 Running python -m SimpleHTTPServer &
$ bg 1
$ open http://0.0.0.0:8000/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment