Category Archives: Contributions to Open Source

Emscripten- Getting started

Imagine that you have written a very large project in C/C++ and now you want the same in Java Script. Will you start writing each piece of code in Java Script? Isn’t it too tedious?

Emscripten is an open source LLVM to JavaScript compiler. Using which, you can compile C and C++ code into JavaScript and run it on the web. This avoids the need to write the whole bunch of code program from the scratch.

Some of the requirements before using emscripten:[1]

  • The Emscripten code, from github (git clone git://github.com/kripken/emscripten.git)
  • LLVM with Clang (3.1 is the officially supported version)
  • Node.js (0.5.5 or above)
  • Python 2.6

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies. Clang is a new C/C++/Objective-C/Objectice-C++ compiler being developed on top of LLVM. This must be a good replacement for gcc.

Here are the steps to build and install clang. [2]

  1. mkdir /path/to/clang-build
  2. cd /path/to/clang-build
  3. cd llvm/tools
  4. cd ../..
  5. mkdir build
  6. cd build
  7. ../llvm/configure –enable-optimized –disable-assertions
  8. make && sudo make install

Node.js: In order to execute the JavaScript you intend to run in the backend, it needs to be interpreted and, well, executed. This is what Node.js does. [3]

1. git clone https://github.com/joyent/node.git
2. cd node
3. ./configure
4. make
5. sudo make install

Once you have successfully done this. The next step is to setup emscripten. You can run emscripten by typing ./emcc. This ma throw some error if the path to clang and node is not correct.

Now we can compile the first helloworld file using emscripten.

./emcc tests/hello_world.cpp
  node a.out.js

Hello world! gets printed 🙂
Hope this post helped you get started with emscripten.

[1] https://github.com/kripken/emscripten/wiki/Tutorial
[2] http://ehsanakhgari.org/blog/2011-10-18/why-you-should-switch-clang-today-and-how
[3] http://samcaldwell.net/index.php/technical-articles/3-how-to-articles/120-how-do-i-install-nodejs-on-ubuntu-1004

Advertisements

Bug Fix in Gcompris

I was searching for an application to contribute so as to become eligible to apply for Gnome Women Outreach Program 2012 [1]. And I selected Gcompris, which is a educational software that contains various activities for children of age group 2-10. This seems interesting for me.

This is the bug that I fixed

http://git.gnome.org/browse/gcompris/commit/?id=74d911d10308db5ee1680a187e8dff3b8ece9add

 

DESCRIPTION:

 In money activity, when the player enters wrong change, the bonus lost is not displayed.

But in matching word game it is displayed when wrong match is selected. So I implemented the same in money activity game.

FIX- The bonus lost is now displayed in case the children click ok and the answer is wrong.

Thanks to my senior Arvind who helped in fixing this issue.
Thanks to Bruno Coudoin, the mentor for Gcompris.

 

 

 

My first contribution to Open Source

This was my first contribution to open source.  I fixed a bug!
The bug was to add a new word ‘quinoa’  into Firefox dictionary.

https://bugzilla.mozilla.org/show_bug.cgi?id=704394#c1

A few things that I learned :

1) Building and installing from source
2) Keeping in contact with the mentor and updating him every 2-3 days.
3) Creating a patch and asking for review
4) Updating the tree every time you do new stuffs
5) Working around multiple bugs that may cause weird patches :)
6) Reading source code
7) Using Internet Relay chat
8) Proper documentation

This was a great experience for me.

Thanks to my mentor Ehsan Akhgari who helped me through out the process.