Cross-compiling Node.js for ARM6 (Raspberry Pi)

Adam M-W picture Adam M-W · Jun 14, 2012 · Viewed 13.2k times · Source

I'm trying to get node.js v0.7.9 to compile for the raspberry pi, but as node and v8 are quite large, I'm hoping to be able to cross-compile on another more powerful PC. I'm using the linux-x86 arm-bcm2708-linux-gnueabi toolchain from https://github.com/raspberrypi/tools and have used them to successfully build other executables for the system. I ended up setting the CC,CXX,CPP,STRIP,OBJCOPY,etc. variables to the toolchain equivalents in the environmental variables and ran configure with: ./configure --dest-cpu=arm --without-snapshot to get the final executable. Copying it over to the system and running it however produces the following error:

Extension or internal compilation error at line 0.
Segmentation fault

However, the segmentation fault doesn't happen for any of the non-javascript tasks like node --version and node --help. Are there any CFLAGS/CXXFLAGS I might be missing causing this problem? Bit confused....

Answer

Alexandre Alapetite picture Alexandre Alapetite · Jun 21, 2012

NodeJS is available pre-compiled for a few Linux distributions: https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager

Since NodeJS is still in testing phase for Debian, in order to install NodeJS on my Raspberry Pi under Debian wheezy, I do:

sudo su
echo deb ftp://ftp.dk.debian.org/debian/ sid main > /etc/apt/sources.list.d/sid.list
apt-get update
apt-get install nodejs
rm /etc/apt/sources.list.d/sid.list
apt-get update
exit

NodeJS works very fine and stable on my Raspberry Pi.