编译32位系统上的node.js

我需要在32位系统上编译node.js以与我已有的代码兼容。

我从nodejs.org的源代码开始编译它。 然后,我开始通过改变common.gypi文件中的第164-166行。 它是:

164 [ 'target_arch=="x64"', { 165 'cflags': [ '-m64' ], 166 'ldflags': [ '-m64' ], 167 }], 

现在是:

 164 [ 'target_arch=="x64"', { 165 'cflags': [ '-m32' ], 166 'ldflags': [ '-m32' ], 167 }], 

当我试图再次,我得到这些错误:

../deps/v8/src/execution.h:259:错误:整数常量对于“长”types来说太大../deps/v8/src/execution.h:260:错误:整型常量太大'long'type ../deps/v8/src/execution.h:259:error:函数调用不能出现在常量expression式中../deps/v8/src/execution.h:260:error:a function调用不能出现在一个常量expression式中

这些错误是指这些行:

 #ifdef V8_TARGET_ARCH_X64 static const uintptr_t kInterruptLimit = V8_UINT64_C(0xfffffffffffffffe); static const uintptr_t kIllegalLimit = V8_UINT64_C(0xfffffffffffffff8); 

我相信这个代码是从谷歌的V8源代码。

我将不胜感激任何如何解决这些特定的编译错误和/或如何在32位系统上编译64位node.js的build议。 大部分我所做的研究是如何为64位系统编译32位的东西。

如果您要构buildx86_32版本的节点,那么您正在修改错误目标体系结构的参数。 相反,将--dest-cpu参数赋予configuration脚本,如下所示:

 git clone git://github.com/joyent/node.git cd node ./configure --prefix /usr/local --dest-cpu ia32 make 

如果这些命令成功完成,则在./out/Release/node应该有一个工作的x86_32二进制./out/Release/node

 ~/node$ file -b ./out/Release/node ELF 32-bit LSB executable, Intel 80386, version 1 (GNU/Linux), dynamically linked (uses shared libs), for GNU/Linux 2.6.26, (...), not stripped ~/node$ ./out/Release/node > 1 + 1 2 

您可以使用sudo make install将其安装在正在运行的系统中(在前面的--prefix参数中指定的前缀处)。

请注意,这需要设置一个工作的C和C ++编译器。 在Debian / Ubuntu上, sudo apt-get install build-essential (或者build-essential:i386如果你正在交叉编译的话, build-essential:i386 )应该让你开始。 在基于rpm的发行版上,试试sudo yum groupinstall "Development Tools" "Development Libraries"

Interesting Posts