为 Linux 嵌入式开发环境 (LEDE)(与 OpenWRT 相同)编译自定义包
Compiling custom package for Linux Embedded Development Environment (LEDE) (same as OpenWRT)
Hi all,
平台:x86_64
我成功安装了 Linux 嵌入式开发环境 (LEDE) x86/64(与 OpenWRT 相同)到我的虚拟机。
我使用 SDK 为 Linux 嵌入式开发环境 (LEDE) 开发了自定义包 "Hello World" 并对其进行了交叉编译。然后,在我的虚拟机上测试它,它工作。
但是,然后我有自己的代码要移植,即用于 c 中的原始数据包嗅探器,我想移植该代码。因此,我在用于 "Hello world" (helloworld.c) 的同一个文件下复制了相同的代码。再一次,我成功地交叉编译了新的二进制“*.ipk 格式”,然后将它发送到我的 LEDE 虚拟机上并做了 opkg install xxxxxx.ipk
。它安装了,但输出相同。我是说 "Hello world".
我不知道怎么办。因为,这次代码变了。然后,再次为测试写了一个简单的阶乘代码并再次。在虚拟机中测试期间。我发现它不起作用,因为再次输出相同的结果,即 "Hello world".
文档:Hello world package for LEDE using LEDE Source
我正在使用 SDK 而不是 source.I 进行开发,遵循文档中的所有内容,不包括源代码编译和所有内容。
SDK 文档:Compile custom package using SDK
Hello World 代码的 Makefile:
include $(TOPDIR)/rules.mk
# Name, version and release number
# The name and version of your package are used to define the variable to point to the build directory of your package: $(PKG_BUILD_DIR)
PKG_NAME:=helloworld
PKG_VERSION:=1.0
PKG_RELEASE:=1
# Source settings (i.e. where to find the source codes)
# This is a custom variable, used below
SOURCE_DIR:=/home/buildbot/helloworld
include $(INCLUDE_DIR)/package.mk
# Package definition; instructs on how and where our package will appear in the overall configuration menu ('make menuconfig')
define Package/helloworld
SECTION:=examples
CATEGORY:=Examples
TITLE:=Hello, World!
endef
# Package description; a more verbose description on what our package does
define Package/helloworld/description
A simple "Hello, world!" -application.
endef
# Package preparation instructions; create the build directory and copy the source code.
# The last command is necessary to ensure our preparation instructions remain compatible with the patching system.
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
cp $(SOURCE_DIR)/* $(PKG_BUILD_DIR)
$(Build/Patch)
endef
# Package build instructions; invoke the target-specific compiler to first compile the source file, and then to link the file into the final executable
define Build/Compile
$(TARGET_CC) $(TARGET_CFLAGS) -o $(PKG_BUILD_DIR)/helloworld.o -c $(PKG_BUILD_DIR)/helloworld.c
$(TARGET_CC) $(TARGET_LDFLAGS) -o $(PKG_BUILD_DIR)/ $(PKG_BUILD_DIR)/helloworld.o
endef
# Package install instructions; create a directory inside the package to hold our executable, and then copy the executable we built previously into the folder
define Package/helloworld/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/helloworld $(1)/usr/bin
endef
# This command is always the last, it uses the definitions and variables we give above in order to get the job done
$(eval $(call BuildPackage,helloworld))
我再次交叉编译了相同的代码并使用 LinkIt Smart 7688
对其进行了测试,一切都按预期工作。所以,我认为我为测试创建的 LEDE 虚拟机出了点问题。
LinkIt Smart 7688:
It is an open development board which is based on OpenWrt Linux distribution and MT7688.
The platform also offers options to create device applications in
Python, Node.js and C programming language.
So, I think It is one of the best board available for IoT things within 12.90 US Dollars.
我在openwrt中添加自定义包成功,这是我的Makefile,希望对你有帮助
include $(TOPDIR)/rules.mk
PKG_NAME:=viva
PKG_VERSION:=1.4
PKG_RELEASE=$(PKG_SOURCE_VERSION)
PKG_MAINTAINER:=Vishal <yourname@domain.for.your.name>
PKG_LICENSE:=ISC
include $(INCLUDE_DIR)/package.mk
define Package/viva/default
CATEGORY:=Network
SUBMENU:=Web Servers/Proxies
TITLE:=Webpage for package creation
endef
define Package/viva
$(Package/viva/default)
DEPENDS:=+uhttpd
endef
define Package/viva/description
A web page used for illustrating package creation
endef
define Package/viva/install
$(CP) ./files/* $(1)/
endef
define Build/Compile
true
endef
$(eval $(call BuildPackage,viva))
Hi all,
平台:x86_64
我成功安装了 Linux 嵌入式开发环境 (LEDE) x86/64(与 OpenWRT 相同)到我的虚拟机。
我使用 SDK 为 Linux 嵌入式开发环境 (LEDE) 开发了自定义包 "Hello World" 并对其进行了交叉编译。然后,在我的虚拟机上测试它,它工作。
但是,然后我有自己的代码要移植,即用于 c 中的原始数据包嗅探器,我想移植该代码。因此,我在用于 "Hello world" (helloworld.c) 的同一个文件下复制了相同的代码。再一次,我成功地交叉编译了新的二进制“*.ipk 格式”,然后将它发送到我的 LEDE 虚拟机上并做了 opkg install xxxxxx.ipk
。它安装了,但输出相同。我是说 "Hello world".
我不知道怎么办。因为,这次代码变了。然后,再次为测试写了一个简单的阶乘代码并再次。在虚拟机中测试期间。我发现它不起作用,因为再次输出相同的结果,即 "Hello world".
文档:Hello world package for LEDE using LEDE Source 我正在使用 SDK 而不是 source.I 进行开发,遵循文档中的所有内容,不包括源代码编译和所有内容。
SDK 文档:Compile custom package using SDK
Hello World 代码的 Makefile:
include $(TOPDIR)/rules.mk
# Name, version and release number
# The name and version of your package are used to define the variable to point to the build directory of your package: $(PKG_BUILD_DIR)
PKG_NAME:=helloworld
PKG_VERSION:=1.0
PKG_RELEASE:=1
# Source settings (i.e. where to find the source codes)
# This is a custom variable, used below
SOURCE_DIR:=/home/buildbot/helloworld
include $(INCLUDE_DIR)/package.mk
# Package definition; instructs on how and where our package will appear in the overall configuration menu ('make menuconfig')
define Package/helloworld
SECTION:=examples
CATEGORY:=Examples
TITLE:=Hello, World!
endef
# Package description; a more verbose description on what our package does
define Package/helloworld/description
A simple "Hello, world!" -application.
endef
# Package preparation instructions; create the build directory and copy the source code.
# The last command is necessary to ensure our preparation instructions remain compatible with the patching system.
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
cp $(SOURCE_DIR)/* $(PKG_BUILD_DIR)
$(Build/Patch)
endef
# Package build instructions; invoke the target-specific compiler to first compile the source file, and then to link the file into the final executable
define Build/Compile
$(TARGET_CC) $(TARGET_CFLAGS) -o $(PKG_BUILD_DIR)/helloworld.o -c $(PKG_BUILD_DIR)/helloworld.c
$(TARGET_CC) $(TARGET_LDFLAGS) -o $(PKG_BUILD_DIR)/ $(PKG_BUILD_DIR)/helloworld.o
endef
# Package install instructions; create a directory inside the package to hold our executable, and then copy the executable we built previously into the folder
define Package/helloworld/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/helloworld $(1)/usr/bin
endef
# This command is always the last, it uses the definitions and variables we give above in order to get the job done
$(eval $(call BuildPackage,helloworld))
我再次交叉编译了相同的代码并使用 LinkIt Smart 7688
对其进行了测试,一切都按预期工作。所以,我认为我为测试创建的 LEDE 虚拟机出了点问题。
LinkIt Smart 7688: It is an open development board which is based on OpenWrt Linux distribution and MT7688. The platform also offers options to create device applications in Python, Node.js and C programming language.
So, I think It is one of the best board available for IoT things within 12.90 US Dollars.
我在openwrt中添加自定义包成功,这是我的Makefile,希望对你有帮助
include $(TOPDIR)/rules.mk
PKG_NAME:=viva
PKG_VERSION:=1.4
PKG_RELEASE=$(PKG_SOURCE_VERSION)
PKG_MAINTAINER:=Vishal <yourname@domain.for.your.name>
PKG_LICENSE:=ISC
include $(INCLUDE_DIR)/package.mk
define Package/viva/default
CATEGORY:=Network
SUBMENU:=Web Servers/Proxies
TITLE:=Webpage for package creation
endef
define Package/viva
$(Package/viva/default)
DEPENDS:=+uhttpd
endef
define Package/viva/description
A web page used for illustrating package creation
endef
define Package/viva/install
$(CP) ./files/* $(1)/
endef
define Build/Compile
true
endef
$(eval $(call BuildPackage,viva))