Openwrt:What 可以把bin文件打包成ipk包吗?
Openwrt:What can I do to package bin files into ipk packages?
我已经编译了 openwrt 源代码,运行 它在我的设备 (HC5661) 上。然后我使用 Eclipse IDE 写了一个 helloword.cpp (一个例子,任何其他名称) ,helloword.bin在目标设备上使用sftp编译调试成功,gdb.Now想把helloword编译成ipk包.如何将bin文件打包成ipk包?
你必须使用SDK
。您可以按照以下步骤操作:
1) 下载 OpenWrt-SDK
2) 在 OpenWrt-SDK
文件夹中 运行 ./scripts/feeds/update -a && ./scripts/feeds/install -a
3) 在路径 OpenWrt-SDK/feeds/packages/utils/
中创建名为 helloworld
的文件夹
4) 在此文件夹中创建一个名为 Makefile
的文件和一个名为 src
.
的新文件夹
5) 在 src
文件夹中放入您的 helloworld.cpp
和允许编译它的 Makefile
。
6) 文件夹 OpenWrt-SDK/scripts/feeds/packages/utils/
中的 Makefile
应如下所示:
include $(TOPDIR)/rules.mk
# Name and release number of this package
PKG_NAME:=helloworld
PKG_VERSION:=1.0
PKG_RELEASE:=0
# This specifies the directory where we're going to build the program.
# The root build directory, $(BUILD_DIR), is by default the build_mipsel
# directory in your OpenWrt SDK directory
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
include $(INCLUDE_DIR)/uclibc++.mk
include $(INCLUDE_DIR)/package.mk
# Specify package information for this program.
# The variables defined here should be self explanatory.
define Package/helloworld
SECTION:=utils
CATEGORY:=Utilities
TITLE:=helloworld exampke
endef
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
$(CP) ./src/* $(PKG_BUILD_DIR)/
endef
TARGET_CFLAGS += \
-I$(STAGING_DIR)/usr/include \
-D_GNU_SOURCE \
-ggdb3
MAKE_FLAGS += \
CFLAGS="$(TARGET_CFLAGS)" \
LDFLAGS="$(TARGET_LDFLAGS)"
define Build/Compile
$(call Build/Compile/Default, \
CCOPTS="$(TARGET_CFLAGS)" \
INCLUDE="$(EXTRA_CFLAGS)" \
LDFLAGS="$(EXTRA_LDFLAGS)" \
)
endef
define Package/helloworld/install
$(INSTALL_DIR) $(1)/bin
$(CP) $(PKG_BUILD_DIR)/$(PKG_NAME) $(1)/bin/
endef
# This line executes the necessary commands to compile our program.
# The above define directives specify all the information needed, but this
# line calls BuildPackage which in turn actually uses this information to
# build a package.
$(eval $(call BuildPackage,helloworld))
7) 在 OpenWrt-SDK
文件夹中 运行 ./scripts/feeds update -i && ./scripts/feeds install helloworld
8) 在同一文件夹中 运行 make package/helloworld/compile
9) 您可以在 OpenWrt-SDK/bin/ar71xx/packages/packages/
中找到您的 .ipk
包裹
PS:您可能必须通过键入 (Ubuntu) sudo apt-get install ccache
来安装 ccache
。您不得使用空格键入 makefile,必须使用制表符。
如果你已经有hello.bin,你可以把它放到hello/src和:
makefile(你好/):
include $(TOPDIR)/rules.mk
PKG_NAME:=hello
PKG_VERSION:=1.0
include $(INCLUDE_DIR)/package.mk
define Package/hello
CATEGORY:=Examples
TITLE:=hello
DEPENDS:=+libstdcpp
endef
define Package/hello/description
hello world
endef
define Package/hello/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) ./src/hello $(1)/usr/bin
endef
$(eval $(call BuildPackage,hello))
生成文件(hello/src):
all:hello
如果没有,您应该将 hello.cpp 放入 hello/src 并且:
makefile(你好/):
include $(TOPDIR)/rules.mk
PKG_NAME:=hello
PKG_VERSION:=1.0
include $(INCLUDE_DIR)/package.mk
define Package/hello
CATEGORY:=Examples
TITLE:=hello
DEPENDS:=+libstdcpp
endef
define Package/hello/description
hello world
endef
define Package/hello/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/hello $(1)/usr/bin
endef
$(eval $(call BuildPackage,hello))
生成文件(hello/src):
target=hello
all:$(target)
objects=hello.o
hello:$(objects)
$(CXX) -o $(target) $(objects)
clean:
@rm -rf $(objects)
我已经编译了 openwrt 源代码,运行 它在我的设备 (HC5661) 上。然后我使用 Eclipse IDE 写了一个 helloword.cpp (一个例子,任何其他名称) ,helloword.bin在目标设备上使用sftp编译调试成功,gdb.Now想把helloword编译成ipk包.如何将bin文件打包成ipk包?
你必须使用SDK
。您可以按照以下步骤操作:
1) 下载 OpenWrt-SDK
2) 在 OpenWrt-SDK
文件夹中 运行 ./scripts/feeds/update -a && ./scripts/feeds/install -a
3) 在路径 OpenWrt-SDK/feeds/packages/utils/
helloworld
的文件夹
4) 在此文件夹中创建一个名为 Makefile
的文件和一个名为 src
.
5) 在 src
文件夹中放入您的 helloworld.cpp
和允许编译它的 Makefile
。
6) 文件夹 OpenWrt-SDK/scripts/feeds/packages/utils/
中的 Makefile
应如下所示:
include $(TOPDIR)/rules.mk
# Name and release number of this package
PKG_NAME:=helloworld
PKG_VERSION:=1.0
PKG_RELEASE:=0
# This specifies the directory where we're going to build the program.
# The root build directory, $(BUILD_DIR), is by default the build_mipsel
# directory in your OpenWrt SDK directory
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
include $(INCLUDE_DIR)/uclibc++.mk
include $(INCLUDE_DIR)/package.mk
# Specify package information for this program.
# The variables defined here should be self explanatory.
define Package/helloworld
SECTION:=utils
CATEGORY:=Utilities
TITLE:=helloworld exampke
endef
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
$(CP) ./src/* $(PKG_BUILD_DIR)/
endef
TARGET_CFLAGS += \
-I$(STAGING_DIR)/usr/include \
-D_GNU_SOURCE \
-ggdb3
MAKE_FLAGS += \
CFLAGS="$(TARGET_CFLAGS)" \
LDFLAGS="$(TARGET_LDFLAGS)"
define Build/Compile
$(call Build/Compile/Default, \
CCOPTS="$(TARGET_CFLAGS)" \
INCLUDE="$(EXTRA_CFLAGS)" \
LDFLAGS="$(EXTRA_LDFLAGS)" \
)
endef
define Package/helloworld/install
$(INSTALL_DIR) $(1)/bin
$(CP) $(PKG_BUILD_DIR)/$(PKG_NAME) $(1)/bin/
endef
# This line executes the necessary commands to compile our program.
# The above define directives specify all the information needed, but this
# line calls BuildPackage which in turn actually uses this information to
# build a package.
$(eval $(call BuildPackage,helloworld))
7) 在 OpenWrt-SDK
文件夹中 运行 ./scripts/feeds update -i && ./scripts/feeds install helloworld
8) 在同一文件夹中 运行 make package/helloworld/compile
9) 您可以在 OpenWrt-SDK/bin/ar71xx/packages/packages/
.ipk
包裹
PS:您可能必须通过键入 (Ubuntu) sudo apt-get install ccache
来安装 ccache
。您不得使用空格键入 makefile,必须使用制表符。
如果你已经有hello.bin,你可以把它放到hello/src和:
makefile(你好/):
include $(TOPDIR)/rules.mk
PKG_NAME:=hello
PKG_VERSION:=1.0
include $(INCLUDE_DIR)/package.mk
define Package/hello
CATEGORY:=Examples
TITLE:=hello
DEPENDS:=+libstdcpp
endef
define Package/hello/description
hello world
endef
define Package/hello/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) ./src/hello $(1)/usr/bin
endef
$(eval $(call BuildPackage,hello))
生成文件(hello/src):
all:hello
如果没有,您应该将 hello.cpp 放入 hello/src 并且:
makefile(你好/):
include $(TOPDIR)/rules.mk
PKG_NAME:=hello
PKG_VERSION:=1.0
include $(INCLUDE_DIR)/package.mk
define Package/hello
CATEGORY:=Examples
TITLE:=hello
DEPENDS:=+libstdcpp
endef
define Package/hello/description
hello world
endef
define Package/hello/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/hello $(1)/usr/bin
endef
$(eval $(call BuildPackage,hello))
生成文件(hello/src):
target=hello
all:$(target)
objects=hello.o
hello:$(objects)
$(CXX) -o $(target) $(objects)
clean:
@rm -rf $(objects)