Fixed compilation errors under Linux.
Added type casts to make gcc happy.
Added -lpthread when compiling with the Boehm GC on platforms other than Windows.