安裝編譯環境:
代碼如下 |
複製代碼 |
apt-get install build-essential libncurses5-dev zlib1g-dev
|
下載交叉編譯環境及sshpass源碼:
代碼如下 |
複製代碼 |
wget http://downloads.openwrt.org/backfire/10.03.1/brcm63xx/OpenWrt-SDK-brcm63xx-for-Linux-i686-gcc-4.3.3%2bcs_uClibc-0.9.30.1.tar.bz2 tar jxvf OpenWrt-SDK-brcm63xx-for-Linux-i686-gcc-4.3.3+cs_uClibc-0.9.30.1.tar.bz2 mkdir -p OpenWrt-SDK-brcm63xx-for-Linux-i686-gcc-4.3.3+cs_uClibc-0.9.30.1/package/sshpass cd OpenWrt-SDK-brcm63xx-for-Linux-i686-gcc-4.3.3+cs_uClibc-0.9.30.1/package/sshpass wget http://sourceforge.net/projects/sshpass/files/sshpass/1.05/sshpass-1.05.tar.gz tar zxvf sshpass-1.05.tar.gz mv sshpass-1.05 src |
sshpass目錄建立Makefile檔案:
代碼如下 |
複製代碼 |
include $(TOPDIR)/rules.mk # Name and release number of this package PKG_NAME:=sshpass PKG_RELEASE:=1.05 PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME) include $(INCLUDE_DIR)/package.mk define Package/sshpass SECTION:=utils CATEGORY:=Utilities TITLE:=sshpass endef define Package/sshpass/description Sshpass is a tool for non-interactivly performing password authentication with SSH's endef # Specify what needs to be done to prepare for building the package. define Build/Prepare mkdir -p $(PKG_BUILD_DIR) $(CP) ./src/* $(PKG_BUILD_DIR)/ endef # Specify where and how to install the program. define Package/sshpass/install $(INSTALL_DIR) $(1)/bin $(INSTALL_BIN) $(PKG_BUILD_DIR)/sshpass $(1)/bin/ endef # This line executes the necessary commands to compile our program. $(eval $(call BuildPackage,sshpass)) |
編譯sshpass:
代碼如下 |
複製代碼 |
cd ../ make package/sshpass/compile |
編譯成功的程式檔案:
代碼如下 |
複製代碼 |
ls bin/brcm63xx/packages/ Packages Packages.gz sshpass_1.05_brcm63xx.ipk |
編譯過程中如遇到以下錯誤:
代碼如下 |
複製代碼 |
staging_dir/toolchain-mips_r2_gcc-4.3.3+cs_uClibc-0.9.30.1/usr/lib/libc.so: undefined reference to `_dl_app_init_array’ 需修改: |
TARGET_LDFLAGS:=-L$(STAGING_DIR)/usr/lib -L$(STAGING_DIR)/lib
為:
代碼如下 |
複製代碼 |
TARGET_LDFLAGS+= -L$(TOOLCHAIN_DIR)/usr/lib -L$(TOOLCHAIN_DIR)/lib -Wl,-rpath=$(TOOLCHAIN_DIR)/lib |