OpenWrt下交叉編譯Node.js(HG255D)

來源:互聯網
上載者:User

標籤:des   blog   class   c   code   java   

作業系統:deepin linux 2013 或 ubuntu 13.04

1、安裝交叉編譯前,需要安裝的包

sudo apt-get install build-essential subversion git-core libncurses5-dev zlib1g-dev gawk flex quilt xsltproc
2、下載OpenWrt的原始碼

git clone git://git.openwrt.org/openwrt.gitcd openwrt./scripts/feeds update -a./scripts/feeds install -amake defconfigmake prereqmake menuconfig
按照選擇對應的項目



3.關鍵的一步

cd packagemkdir nodesudo 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.28PKG_RELEASE:=2PKG_SOURCE:=node-$(PKG_VERSION).tar.gzPKG_SOURCE_URL:=http://nodejs.org/dist/${PKG_VERSION}#更改版本時也要修改PKG_MD5SUM:=87768be7065d2120e71619948ab4bb2dGYP_DEFINES:=v8_use_mips_abi_hardfloat=false v8_can_use_fpu_instructions=falseLIBS:=-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/descriptionNode.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"endefdefine Package/node/installmkdir -p $(1)/usr/bin$(CP) $(PKG_BUILD_DIR)/out/Release/node $(1)/usr/bin/ln -s /usr/bin/node $(1)/usr/bin/nodejsendef$(eval $(call BuildPackage,node))

4.儲存設定檔後編譯:  make V=99 (參數為輸出調試資訊)

5.把openwrt/bin/ramips/packages下的

node_v0.10.28-2_ramips_24kec.ipk

uclibcxx_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的時候要耐心等待,我第一次安裝的時候等了一會沒有響應,以為編譯失敗了,終止了安裝進程,因此而耗費了很多時間。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.