Skip to content

Instantly share code, notes, and snippets.

@botverse
Created August 30, 2013 13:51
Show Gist options
  • Save botverse/6390061 to your computer and use it in GitHub Desktop.
Save botverse/6390061 to your computer and use it in GitHub Desktop.
Little step by step tutorial to use emscriptem

Little step by step guide to use emscript

git clone https://github.com/kripken/emscripten
sudo apt-get install clang llmv
cd emscripten
./emcc
cd hellocpp
clang -lstdc++ main.cpp Hello.cpp
./a.out #> Hello, nice to meet you!
../emscriptem/emcc main.cpp Hello.cpp
node a.out.js #> Hello, nice to meet you!
#include "Hello.h"
#include <iostream>
using namespace std;
void Hello::greeting()
{
if (formal)
cout << "Hello, nice to meet you!" << endl;
else
cout << "What's up?" << endl;
}
void Hello::setFormal(bool f)
{
formal = f;
}
bool Hello::getFormal()
{
return formal;
}
#ifndef HELLO_H_
#define HELLO_H_
class Hello
{
private:
bool formal;
public:
void greeting();
void setFormal(bool f);
bool getFormal();
};
#endif /*HELLO_H_*/
#include "Hello.h"
int main()
{
Hello *h = new Hello();
h->setFormal(true);
h->greeting();
delete h;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment