Thursday, January 26, 2012

node 0.6.8 refuses to build on Centos 5

The latest node refused to build on my headless dev machine. The problem was that Python fell over when trying to load the bz2 module. This wasn't immediately obvious, as node reports it as a scons error:

scons: Reading SConscript files ...
ImportError: No module named bz2:

(To be fair the line before indicates Python as the culprit, and yes scons is Python, but I was being dim)

It turns out that I'd installed a broken Python 2.7 to begin with. bz2 hadn't compiled and I'd missed it. So I downloaded the latest libbz2 and Python, recompiled and...Python failed to build bz2 again. The issue is that Python is expecting libbz2 to be compiled with position independent code and by default it isn't.

The fix is detailed here: change the Makefile for bzip2 to send the -fPIC flag to the C compiler:


CFLAGS=-Wall -Winline -O2 -g $(BIGFILES)


CFLAGS=-Wall -Winline -O2 -g $(BIGFILES) -fPIC

make clean && make && make install in bzip2
make && make install in Python
make && make install in node

All sorted

1 comment: