Showing posts with label nodejs. Show all posts
Showing posts with label nodejs. Show all posts

Friday, August 17, 2012

Installing node.js on the Raspberry Pi Archlinux

My Raspberry Pi arrived a few weeks ago and I had some problems with getting node.js to build on it. This post is specifically about building node.js from source on Archlinux.

All activity and commands in this tutorial are run on the Raspberry Pi, either via SSH or physical keyboard. It is possible to cross-compile on your laptop/desktop for ARM, but I preferred not to in this case.

Prerequisites

Have the base-devel group installed, you should have a working gcc and friends, along with openssl and zlib. Also install python2-virtualenv and git-core.

Get the source

I usually stay on node bleeding edge so:

$ git clone git://github.com/joyent/node

Use Python2

Since Archlinux uses python3 by default, the configure and build scripts screw up. You can edit the individual files, but I find it easier to just use virtualenv, which will setup the shell environment to use python2 and its libraries.

$ virtualenv2 env
$ source env/bin/activate

Here env is the name of the directory virtualenv will use to store scripts. You can use some other name. Sourcing the activate script will set up the environment so that python will actually be python2.

Patch the source

Geoff Flarity has created a patch to tweak the build parameters a bit. You can either follow the instructions to apply the patch, or just comment the 12 vfp3:on... lines yourself, which is what I did. Also set the environment variables to build for ARM as in the README.

export GYP_DEFINES="armv7=0"
export CCFLAGS='-march=armv6'
export CXXFLAGS='-march=armv6'`

NOTE: All commands should be run in the same shell that has the virtualenv environment and the above variables set.

Use system zlib and openssl

Attempting to compile the included openssl failed on my Archlinux setup with some ARM assembly errors. Using the installed libs will also reduce the compilation time. So

$ ./configure --shared-openssl\
--shared-openssl-includes=/usr/include/openssl\
--shared-openssl-libpath=/usr/lib\
--shared-zlib\
--shared-zlib-includes=/usr/include\
--shared-zlib-libpath=/usr/lib

Build

$ make
$ su -c 'make install'

The build will take some time (30 minutes to an hour), so be patient. Once it is done you will have a fully working node runtime on your Raspberry Pi. Use it to power your home automation control server or whatever else. I use it to experiment with my DHT implementation.

The use of node.js to write low-level systems services or networking code over traditional languages like C/C++ is very interesting, because it provides a safer, garbage-collected runtime, with efficient I/O and a less verbose language. Inexpensive devices like the Raspberry Pi allow experimenting with multiple devices or peer-to-peer configurations rather than being bound to only localhost testing for those on a tight budget. So get a Pi and have fun.

Saturday, April 30, 2011

Why I love open source


Someone who found my code interesting, can use it as a launchpad and take it ahead!

Wednesday, December 15, 2010

Introducing Mugshot

There is a certain fun in hacks, little projects you do on a whim and finish in a few days. And then you go and buy a domain for it and launch it. That's Mugshot.

Mugshot is a web service which offers face-detection. It uses the libface library which was implemented mainly as a Google Summer of Code project for KDE. So one day I was thinking that services like Facebook and Flickr allow you to upload images and then tag them. But why not let the faces be detected automatically. So I hacked out Mugshot. It doesn't wrap the entire libface api for node.js, but only one function to detect the faces. Further details can be found on the website, including the documentation.

At the moment libface can stumble on some faces, but when it works, the results can be quite interesting! That image is by Pierre Tourigny and is under the Creative Commons Share-alike Attribution license. Its used to avoid uploading any real faces.

Are there plans to add recognition support and other advanced services? I don't know, maybe if I have a whim. Meanwhile, go fork it.

Posted via email from nikhil's posterous

Sunday, August 29, 2010

Knocked out of Node Knockout

(This is one of those you-don’t-really-have-to-read-it kind of posts)

I was very excited about Node Knockout. I had a great idea for an IRC bouncer + websocket based client called Ircsome using node, qooxdoo and a couple of other things.

I knew that I would only get 24 hours since Sunday had higher priority events, but I believed I could get the basic app working in 24 hours. Until things went downhill from last week. First my brand new shoes tore, and since Adidas has an idiotic replacement policy (even in their centralised, computer based inventory systems) where-in you’ve to go to the same store you bought it from, I lost about 3 hours of my time at home ( although I managed to pick up Erlang Programming. Then in the train home, I rebooted my cell phone and my SIM card just gave, it refused to work. There went my internet connection, no frequent push-pulls. Still I managed to get the client and server atleast talking to each other and logging onto IRC when the user filled in the details in the browser. I pushed out the changes over my home connection, and the push to Joyent succeeded, yet my server didn’t seem to be running, atleast my home internet configuration couldn’t manage to connect to it on any of the expected ports (even though push to the same server worked). By this time I was really annoyed, and had to sleep to, so I stopped. Knockout!

I plan to continue on Ircsome though, so I can deploy my own home brewed bouncer on my (coming soon) VPS and access IRC and logs from anywhere. Qooxdoo is a pretty great toolkit, but lacking certain kinds of documentation and being very heavy in size. Its almost like Qt, though I dislike the Java getter naming convention.

Posted via email from nikhil's posterous