[分享+存档]在Cubieboard ARMv7编译Nodejs三个版本
[分享+存档]在Cubieboard ARMv7编译Nodejs三个版本
我的Cubieboard系统,基于Linaro-Nano: http://cn.cubieboard.org/forum.php?mod=viewthread&tid=347 ps:谢谢chinaspc同学啊啊啊啊啊啊~~
我编译的时候只安装在自己的目录里,用<code>ln -s</code>来切换版本,可以参考这里 https://increaseyourgeek.wordpress.com/2010/08/18/install-node-js-without-using-sudo/
参考ArchLinuxARM的PKGBuild的History,可以自己编译ARM版的Node.js了 https://github.com/archlinuxarm/PKGBUILDs/commits/master/community/nodejs
这里是for 0.6.19 only的: 在PKGBuild有段很重要的注释,导向了一个解决0.6.19的办法 https://github.com/joyent/node/issues/2131#issuecomment-3208846
当然,A10是Armv7-a,这里要把东西参数改一下,进入node的源码目录里的deps/v8,找到SConstruct,编辑之
在82行加入armv7-a,修改完后是这样的 <pre><code>80 ‘gcc’: { 81 ‘all’: { 82 ‘CCFLAGS’: [’$DIALECTFLAGS’, ‘$WARNINGFLAGS’, ‘-march=armv7-a’], </code></pre> 在1083改为hard,修改完后是这样的 <pre><code>1081 ‘armeabi’: { 1082 ‘values’: [‘hard’, ‘softfp’, ‘soft’], 1083 ‘default’: ‘hard’, </code></pre> <p>保存退出</p>
在node的源码根目录,建立一个install.sh文件,把对应版本的注释去掉,按Enter前看看有没有错误信息,比如没找到ssl之类的
#for 0.10.5
#export GYPFLAGS="-Darmeabi=hard -Dv8_use_arm_eabi_hardfloat=true -Dv8_can_use_vfp3_instructions=true -Dv8_can_use_vfp2_instructions=true -Darm7=1"
#./configure --prefix=/home/bigmusic/opt/node-v0.10.5 --without-snapshot --with-arm-float-abi=hard
#for 0.8.22
#export GYPFLAGS="-Darmeabi=hard -Dv8_use_arm_eabi_hardfloat=true -Dv8_can_use_vfp3_instructions=true -Dv8_can_use_vfp2_instructions=true -Darm7=1"
#./configure --prefix=/home/bigmusic/opt/node-v0.8.22 --without-snapshot --with-arm-float-abi=hard
#for 0.6.19
#./configure --prefix=/home/bigmusic/opt/node-v0.6.19 --without-snapshot --openssl-libpath=/usr/lib/ssl --openssl-includes=/usr/include/openssl
read -n 1 -p “Press ENTER to Continue or Press Ctrl+C to exit…”
make clean
make
make install
<p>键入./install.sh进行编译,路径要自己改好喔</p>
[分享+存档] 在Cubieboard ARMv7 编译 Node.js 三个版本
系统环境
我的 Cubieboard 系统基于 Linaro-Nano:
- Cubieboard 论坛链接
- 感谢 chinaspc 同学的支持!
安装方法
编译时只安装在我的用户目录下,并使用 ln -s
来切换版本。可以参考以下链接:
编译步骤
参考 ArchLinuxARM 的 PKGBuild 历史记录,可以自行编译 ARM 版本的 Node.js。
针对特定版本(如 0.6.19)
在 PKGBuild 中有一段重要的注释,指向了解决 0.6.19 版本问题的方法。
由于 A10 是 Armv7-a 架构,需要将某些参数进行修改。进入 node 的源码目录中的 deps/v8
文件夹,找到 SConstruct
文件并编辑它:
# 打开 SConstruct 文件
nano deps/v8/SConstruct
# 在第 82 行添加 armv7-a
80 'gcc': {
81 'all': {
82 'CCFLAGS': ['$DIALECTFLAGS', '$WARNINGFLAGS', '-march=armv7-a'],
然后,在第 1083 行改为 hard
:
1081 'armeabi': {
1082 'values': ['hard', 'softfp', 'soft'],
1083 'default': 'hard',
保存并退出。
编译脚本
在 node 源码根目录中,创建一个 install.sh
文件,用于编译不同版本的 Node.js。
#!/bin/bash
# for 0.10.5
# export GYPFLAGS="-Darmeabi=hard -Dv8_use_arm_eabi_hardfloat=true -Dv8_can_use_vfp3_instructions=true -Dv8_can_use_vfp2_instructions=true -Darm7=1"
# ./configure --prefix=/home/bigmusic/opt/node-v0.10.5 --without-snapshot --with-arm-float-abi=hard
# for 0.8.22
# export GYPFLAGS="-Darmeabi=hard -Dv8_use_arm_eabi_hardfloat=true -Dv8_can_use_vfp3_instructions=true -Dv8_can_use_vfp2_instructions=true -Darm7=1"
# ./configure --prefix=/home/bigmusic/opt/node-v0.8.22 --without-snapshot --with-arm-float-abi=hard
# for 0.6.19
# ./configure --prefix=/home/bigmusic/opt/node-v0.6.19 --without-snapshot --openssl-libpath=/usr/lib/ssl --openssl-includes=/usr/include/openssl
read -n 1 -p "Press ENTER to Continue or Press Ctrl+C to exit..."
make clean
make
make install
运行编译
键入 ./install.sh
进行编译,确保路径正确:
chmod +x install.sh
./install.sh
通过上述步骤,你可以成功地在 Cubieboard ARMv7 上编译和安装多个版本的 Node.js。
性能如何,记得以前编译过arm的PHP,性能奇差。
在Cubieboard ARMv7上编译不同版本的Node.js,可以通过修改源码和配置脚本来实现。以下是具体的步骤和示例代码。
编译环境准备
确保你的Cubieboard已经安装了必要的编译工具和依赖库。通常需要安装gcc
, g++
, make
, 和其他开发工具:
sudo apt-get update
sudo apt-get install build-essential libssl-dev
修改源码以适应A10的ARMv7-a架构
- 进入Node.js源码目录下的
deps/v8
目录,编辑SConstruct
文件:- 在第82行添加
-march=armv7-a
。 - 在第1083行将
'default': 'soft'
改为'default': 'hard'
。
- 在第82行添加
# deps/v8/SConstruct
80 ‘gcc’: {
81 ‘all’: {
82 ‘CCFLAGS’: [’$DIALECTFLAGS’, ‘$WARNINGFLAGS’, ‘-march=armv7-a’],
...
1081 ‘armeabi’: {
1082 ‘values’: [‘hard’, ‘softfp’, ‘soft’],
1083 ‘default’: ‘hard’,
创建安装脚本
在Node.js源码根目录下创建一个install.sh
文件,并按需注释掉不同版本的配置。
# install.sh
#!/bin/bash
# for 0.10.5
# export GYPFLAGS="-Darmeabi=hard -Dv8_use_arm_eabi_hardfloat=true -Dv8_can_use_vfp3_instructions=true -Dv8_can_use_vfp2_instructions=true -Darm7=1"
# ./configure --prefix=/home/user/opt/node-v0.10.5 --without-snapshot --with-arm-float-abi=hard
# for 0.8.22
# export GYPFLAGS="-Darmeabi=hard -Dv8_use_arm_eabi_hardfloat=true -Dv8_can_use_vfp3_instructions=true -Dv8_can_use_vfp2_instructions=true -Darm7=1"
# ./configure --prefix=/home/user/opt/node-v0.8.22 --without-snapshot --with-arm-float-abi=hard
# for 0.6.19
# ./configure --prefix=/home/user/opt/node-v0.6.19 --without-snapshot --openssl-libpath=/usr/lib/ssl --openssl-includes=/usr/include/openssl
read -n 1 -p "Press ENTER to Continue or Press Ctrl+C to exit..."
make clean
make
make install
编译和安装
使用chmod +x install.sh
赋予执行权限,然后运行./install.sh
进行编译和安装。
chmod +x install.sh
./install.sh
这样,你就可以在Cubieboard上编译和安装不同版本的Node.js了。记得根据你的实际路径和版本调整脚本中的路径和配置。