Welcome 微信登录
编程资源 图片资源库 蚂蚁家优选 PDF转换器

首页 / 操作系统 / Linux / OpenWrt下交叉编译Node.js(HG255D)

操作系统:Deepin Linux 2013 或 Ubuntu 13.041、安装交叉编译前,需要安装的包sudo apt-get install build-essential subversion git-core libncurses5-dev zlib1g-dev gawk flex quilt xsltproc2、下载OpenWrt的源代码git clone git://git.openwrt.org/openwrt.git
cd openwrt
./scripts/feeds update -a
./scripts/feeds install -a
make defconfig
make prereq
make menuconfig按照下图选择对应的项目Qtopia运行在OpenWRT上的相关说明 http://www.linuxidc.com/Linux/2013-07/87624.htm基于Tiny210v2编译OpenWrt http://www.linuxidc.com/Linux/2013-07/87621.htmNode.Js入门[PDF+相关代码] http://www.linuxidc.com/Linux/2013-06/85462.htmNode.js入门开发指南中文版 http://www.linuxidc.com/Linux/2012-11/73363.htmNode.js安装与配置 http://www.linuxidc.com/Linux/2013-05/84836.htmUbuntu 编译安装Node.js http://www.linuxidc.com/Linux/2013-10/91321.htm3.关键的一步cd package
mkdir node
sudo gedit Makefile#
# Copyright (C) 2006-2011 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#include $(TOPDIR)/rules.mkPKG_NAME:=node
#目前最新版本
PKG_VERSION:=v0.10.28
PKG_RELEASE:=2PKG_SOURCE:=node-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=http://nodejs.org/dist/${PKG_VERSION}
#更改版本时也要修改
PKG_MD5SUM:=87768be7065d2120e71619948ab4bb2dGYP_DEFINES:=v8_use_mips_abi_hardfloat=false v8_can_use_fpu_instructions=false
LIBS:=-I$(TOOLCHAIN_DIR)/mipsel-openwrt-linux-uclibc/include/c++/4.8.3/ -I$(TOOLCHAIN_DIR)/mipsel-openwrt-linux-uclibc/include/c++/4.8.3/mipsel-openwrt-linux-uclibc/include $(INCLUDE_DIR)/package.mkdefine Package/node
  DEPENDS:=+libpthread +librt +uclibcxx
  SECTION:=lang
  CATEGORY:=Languages
  TITLE:=Node.js is a platform built on Chrome"s JavaScript runtime
  URL:=http://nodejs.org/
endefdefine Package/node/description
Node.js is a platform built on Chrome"s JavaScript runtime for easily building fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices.
endefdefine Build/Prepare
 $(call Build/Prepare/Default)
 $(CP) node.patch $(PKG_BUILD_DIR)/
 (cd $(PKG_BUILD_DIR);
 patch -p1 < node.patch;
 );
endefdefine Build/Configure
 (cd $(PKG_BUILD_DIR);
 export LIBS="$(LIBS)";
 export CFLAGS="$(TARGET_CFLAGS) $(LIBS)";
 export CXXFLAGS="$(TARGET_CXXFLAGS) $(LIBS)";
    export GYPFLAGS="$(GYPFLAGS)";
 ./configure --dest-cpu=mipsel --dest-os=linux --without-ssl --without-snapshot --with-arm-float-abi=soft;
 );
endefdefine Build/Compile
 $(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) GYP_DEFINES="$(GYP_DEFINES)" CC="$(TARGET_CC)" CXX="$(TARGET_CXX)" CFLAGS="$(TARGET_CFLAGS) $(LIBS)" CXXFLAGS="$(TARGET_CXXFLAGS) $(LIBS) -nostdinc++" LDFLAGS="$(TARGET_LDFLAGS) -nodefaultlibs -luClibc++ -lc -lgcc -lgcc_s -lpthread" || touch $(PKG_BUILD_DIR)/deps/v8/build/common.gypi
 $(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) GYP_DEFINES="$(GYP_DEFINES)" CC="$(TARGET_CC)" CXX="$(TARGET_CXX)" CFLAGS="$(TARGET_CFLAGS) $(LIBS)" CXXFLAGS="$(TARGET_CXXFLAGS) $(LIBS) -nostdinc++" LDFLAGS="$(TARGET_LDFLAGS) -nodefaultlibs -luClibc++ -lc -lgcc -lgcc_s -lpthread"
endef
define Package/node/install
 mkdir -p $(1)/usr/bin
 $(CP) $(PKG_BUILD_DIR)/out/Release/node $(1)/usr/bin/
 ln -s /usr/bin/node $(1)/usr/bin/nodejs
endef$(eval $(call BuildPackage,node))4.保存配置文件后编译: make V=99 (参数为输出调试信息)5.把openwrt/bin/ramips/packages下的node_v0.10.28-2_ramips_24kec.ipkuclibcxx_0.2.4-1_ramips_24kec.ipk懒得自己编译的同学,可以到我的网盘下载http://pan.baidu.com/s/1eQ1Pkdk拷贝到路由器,先安装uclibcxx_0.2.4-1_ramips_24kec.ipk库,再安装node_v0.10.28-2_ramips_24kec.ipk,安装node的时候要耐心等待,我第一次安装的时候等了一会没有响应,以为编译失败了,终止了安装进程,因此而耗费了很多时间。Node.js 的详细介绍:请点这里
Node.js 的下载地址:请点这里 本文永久更新链接地址:http://www.linuxidc.com/Linux/2014-06/102734.htm