2016-08-17 87 views
1

我嘗試導出軟件的OpenWrt和我能夠生成IPK但編譯後的文件總是給我這個錯誤錯誤而OpenWrt的

-ash執行交叉編譯的程序:scanReportProbe :找不到

我試過一切,但我無法使它工作。 是完整的,這是我做了什麼準備環境:

git clone git://github.com/openwrt/openwrt.git 
cd openwrt 
./scripts/feeds update -a 
./scripts/feeds install -a 
make defconfig 
make prereq 
make menuconfig 
    [here i selected the package with the M and saved the configuration] 
make tools/install 
make toolchain/install 
make package/scanReport_probe/compile 

我沒有,所以我需要的解決方案的一些線索來解決這個錯誤的想法。

我不認爲錯誤是在代碼中,但CASSE需要的,這是我的計劃: 文件結構

scanReport_probe 
├── LICENSE 
├── Makefile 
├── README.md 
└── src 
    ├── data 
    │ └── THIS IS FOR DATA FILES.txt 
    ├── runScript 
    │ └── scanReportProbe 
    ├── scanReport_probe 
    │ ├── a.c 
    │ └── makefile 
    └── scanReport_probe.conf 

makefile中的OpenWrt

include $(TOPDIR)/rules.mk 

# name of package 
# version number of the sources you're using 
# how many times you've released a package based on the above version number 
PKG_NAME:=scanReport_probe 
PKG_VERSION:=1.0 
PKG_RELEASE:=1 
PKG_LICENSE:=MIT 

# sources will be unpacked into this directory (you shouldn't need to change this) 
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION) 

#needed 
include $(INCLUDE_DIR)/package.mk 


# Metadata; information about what the package is for the ipkg listings 
# to keep things simple, a number of fields have been left at their defaults 
# and are not shown here. 
define Package/scanReport_probe 
    SECTION:=utils 
    CATEGORY:=Utilities 
    TITLE:=scanReport_probe 
    URL:=https://github.com/luigiDB/scan-report_probe 
    TITLE:=Scan in monitor mode probe over wifi channel with periodic report to a server through http post. 
    MAINTAINER:=Please refer to github repository page 
endef 

define Package/scanReport_probe/description 
    This is the best tool ever. 
    Scan probe over wifi and at regualar interval send results via http post. 
endef 


define Build/Prepare 
    mkdir -p $(PKG_BUILD_DIR) 
    $(CP) ./src/* $(PKG_BUILD_DIR)/ 
endef 


CONFIGURE_VARS+= \ 
    CC="$(TOOLCHAIN_DIR)/bin/$(TARGET_CC)" 


define Build/Compile 
    $(MAKE) -C $(PKG_BUILD_DIR)/scanReport_probe $(TARGET_CONFIGURE_OPTS) 
endef 

# We'll use the OpenWrt defaults to configure and compile the package. Otherwise we'd need to define 
# Build/Configure - commands to invoke a configure (or similar) script 
# Build/Compile - commands used to run make or otherwise build the source 

define Package/scanReport_probe/install 
    # Now that we have the source compiled (magic huh?) we need to copy files out of the source 
    # directory and into our ipkg file. These are shell commands, so make sure you start the lines 
    # with a TAB. $(1) here represents the root filesystem on the router. 
    # INSTALL_DIR, INSTALL_BIN, INSTALL_DATA are used for creating a directory, copying an executable, 
    # or a data file. +x is set on the target file for INSTALL_BIN, independent of it's mode on the host. 

    # make a directory for the config 
    $(INSTALL_DIR) $(1)/etc/scanReport_probe/ 

    # copy the config 
    $(INSTALL_CONF) $(PKG_BUILD_DIR)/scanReport_probe.conf $(1)/etc/scanReport_probe 

    # make a directory for some random data files required by scanReport_probe 
    $(INSTALL_DIR) $(1)/usr/share/scanReport_probe 

    # copy the data files 
    $(INSTALL_DATA) $(PKG_BUILD_DIR)/data/* $(1)/usr/share/scanReport_probe 

    #make directory bin 
    $(INSTALL_DIR) $(1)/bin 

    # copy the binary 
    $(INSTALL_BIN) $(PKG_BUILD_DIR)/scanReport_probe/scanReportProbe $(1)/bin 

    #make the directory init.d in case isn't present 
    $(INSTALL_DIR) $(1)/etc/init.d 

    #copy script to init.d 
    $(INSTALL_BIN) $(PKG_BUILD_DIR)/runScript/scanReportProbe $(1)/etc/init.d  
endef 


#runned post installation call the enable on the service 
define Package/scanReport_probe/postinst 
    #!/bin/sh 
    # check if we are on real system 
    if [ -z "$${IPKG_INSTROOT}" ]; then 
     echo "Enabling rc.d symlink for scanReportProbe" 
     /etc/init.d/scanReportProbe enable 
    fi 
    exit 0 
endef 


#runned pre uninstallation call the disable on the service 
define Package/scanReport_probe/prerm 
    #!/bin/sh 
    # check if we are on real system 
    if [ -z "$${IPKG_INSTROOT}" ]; then 
     echo "Removing rc.d symlink for scanReportProbe" 
     /etc/init.d/scanReportProbe disable 
    fi 
    exit 0 
endef 

$(eval $(call BuildPackage,scanReport_probe)) 

交流

#include <stdio.h> 
int main(void) 
{ 
     printf("Hello World\n"); 
     return 0; 
} 

makefile for c program

PROFILE = -O2 -s 
CFLAGS = $(PROFILE) 
LDFLAGS = 

all: main 

# build it 
main: a.o 
    $(CC) $(LDFLAGS) a.o -o scanReportProbe 

a.o: a.c 
    $(CC) $(CFLAGS) -c a.c 

# clean it 
clean: 
    rm *.o a 
+0

您確定您在menuconfig中選擇了正確的架構嗎? 'file build_dir/target - */scanReport_probe */scanReportProbe'說什麼?將它與來自openwrt設備的二進制文件進行比較(例如,將'/ bin/busybox'複製到主機並運行'file')。 –

+0

另外,嘗試刪除'define Build/Compile'子句和'CONFIGURE_VARS'賦值 - 默認值應該適合你。 –

+0

所有配置都正確。我不知道爲什麼,但編譯這個存儲庫git://git.openwrt.org/15.05/openwrt.git而不是中繼解決了這個問題。 – LuigiDB

回答

0

對於-ash,IIRC,ash是[boot] shell。這是說它無法找到一個特定的命令。

因此,它可能是一個:

(1)在你的rc腳本部分,你在做/etc/init.d/scanReportProbe enable但你正在構建的包使用scanReport_probe。因此,您可能需要在這裏或那裏添加或刪除_和/或一些其他重命名,以便匹配。 (2)如果你給的文件結構是最後一個,我不確定腳本是否在正確的目錄中。

(3)腳本的權限是否正確(即執行)?

+0

安裝完成後,每個文件都在正確的目錄下,而且我還測試了沒有init.d腳本的情況。 bin文件夾下的可執行文件具有執行權限'-rwxr-xr-x 1 root root 1527 Aug 17 17:15 scanReportProbe',但是也有'/ bin/scanReportProbe',我收到相同的錯誤。我還測試了我在網上找到的其他存儲庫,並且每個人都給我提供同樣的錯誤。 – LuigiDB