Hi all,
平台:x86_64
我成功地将Linux嵌入式开发环境(LEDE)x86 / 64(与OpenWRT相同)安装到我的虚拟机中。
我开发了一个定制包" Hello World"用于Linux嵌入式开发环境(LEDE)和SDK并交叉编译它。然后,在我的虚拟机上测试它,它工作。
但是,我有自己的端口代码,对于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)/$1 $(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))
答案 0 :(得分:1)
我再次交叉编译相同的代码并使用LinkIt Smart 7688
进行测试,一切都按预期工作。所以,我认为我为测试创建的LEDE虚拟机出了问题。
LinkIt Smart 7688: 它是一个基于OpenWrt Linux发行版和MT7688的开放式开发板。 该平台还提供了创建设备应用程序的选项 Python,Node.js和C编程语言。
所以,我认为它是12.90美元内物联网最好的板材之一。
答案 1 :(得分:1)
我在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))