OpenWRT 的简单 Hello World 程序
Simple Hello World program for OpenWRT
我正在尝试学习 OpenWRT。
我已经下载了sdk。
在 packages\helloworld
文件夹中创建了一个简单的 helloworld.cpp
文件
在 packages\helloworld
中创建了以下 Makefile
生成文件
include $(TOPDIR)/rules.mk
PKG_NAME:=helloworld
PKG_RELEASE:=1
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
include $(INCLUDE_DIR)/package.mk
define Package/helloworld
SECTION:=utils
CATEGORY:=Utilities
TITLE:=Helloworld -- prints a snarky message
Package/PKG_NAME/description:=\
If you can't figure out what this program does, \\
you're probably brain-dead and need immediate \\
medical attention.
endef
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
$(CP) ./src/* $(PKG_BUILD_DIR)/
endef
define Package/helloworld/install
$(INSTALL_DIR) $(1)/bin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/helloworld $(1)/bin/
endef
$(eval $(call BuildPackage,helloworld))
之后我运行从sdk root
发出命令
我收到以下错误
> naro_uClibc-0.9.33.2$ make V=s make[1]: Entering directory
> '/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2'
> make[2]: Entering directory
> '/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2'
> make[3]: Entering directory
> '/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/package/helloworld' CFLAGS="-O2 -pipe -march=i486 -fno-caller-saves -fhonour-copts
> -Wno-error=unused-but-set-variable -I/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/staging_dir/target-i386_uClibc-0.9.33.2/usr/include
> -I/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/staging_dir/target-i386_uClibc-0.9.33.2/include
> -I/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/staging_dir/toolchain-i386_gcc-4.6-linaro_uClibc-0.9.33.2/usr/include
> -I/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/staging_dir/toolchain-i386_gcc-4.6-linaro_uClibc-0.9.33.2/include " CXXFLAGS="-O2 -pipe -march=i486 -fno-caller-saves -fhonour-copts
> -Wno-error=unused-but-set-variable -I/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/staging_dir/target-i386_uClibc-0.9.33.2/usr/include
> -I/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/staging_dir/target-i386_uClibc-0.9.33.2/include
> -I/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/staging_dir/toolchain-i386_gcc-4.6-linaro_uClibc-0.9.33.2/usr/include
> -I/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/staging_dir/toolchain-i386_gcc-4.6-linaro_uClibc-0.9.33.2/include "
> LDFLAGS="-L/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/staging_dir/target-i386_uClibc-0.9.33.2/usr/lib
> -L/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/staging_dir/target-i386_uClibc-0.9.33.2/lib -L/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/staging_dir/toolchain-i386_gcc-4.6-linaro_uClibc-0.9.33.2/usr/lib -L/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/staging_dir/toolchain-i386_gcc-4.6-linaro_uClibc-0.9.33.2/lib " make -j1 -C
> /home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/build_dir/target-i386_uClibc-0.9.33.2/helloworld/.
> AR=i486-openwrt-linux-uclibc-ar AS="ccache_cc -c -O2 -pipe -march=i486
> -fno-caller-saves -fhonour-copts -Wno-error=unused-but-set-variable" LD=i486-openwrt-linux-uclibc-ld NM=i486-openwrt-linux-uclibc-nm
> CC="ccache_cc" GCC="ccache_cc" CXX="ccache_cxx"
> RANLIB=i486-openwrt-linux-uclibc-ranlib
> STRIP=i486-openwrt-linux-uclibc-strip
> OBJCOPY=i486-openwrt-linux-uclibc-objcopy
> OBJDUMP=i486-openwrt-linux-uclibc-objdump
> SIZE=i486-openwrt-linux-uclibc-size CROSS="i486-openwrt-linux-uclibc-"
> ARCH="i386" ; make[4]: Entering directory
> '/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/build_dir/target-i386_uClibc-0.9.33.2/helloworld'
> make[4]: *** Notargets specified and no makefile found. Stop.
> make[4]: Leaving directory
> '/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/build_dir/target-i386_uClibc-0.9.33.2/helloworld'
> Makefile:32: recipe for target
> '/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/build_dir/target-i386_uClibc-0.9.33.2/helloworld/.built'
> failed make[3]: ***
> [/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/build_dir/target-i386_uClibc-0.9.33.2/helloworld/.built]
> Error 2 make[3]: Leaving directory
> '/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/package/helloworld' package/Makefile:105: recipe for target 'package/helloworld/compile'
> failed make[2]: *** [package/helloworld/compile] Error 2 make[2]:
> Leaving directory
> '/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2'
> package/Makefile:101: recipe for target
> '/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/staging_dir/target-i386_uClibc-0.9.33.2/stamp/.package_compile' failed make[1]: ***
> [/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/staging_dir/target-i386_uClibc-0.9.33.2/stamp/.package_compile] Error 2 make[1]: Leaving directory
> '/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2'
> /home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/include/toplevel.mk:144:
> recipe for target 'world' failed make: *** [world] Error 2
谁能帮我找出错误是什么?
我也在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))
我正在尝试学习 OpenWRT。
我已经下载了sdk。
在 packages\helloworld
文件夹中创建了一个简单的 helloworld.cpp
文件
在 packages\helloworld
生成文件
include $(TOPDIR)/rules.mk
PKG_NAME:=helloworld
PKG_RELEASE:=1
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
include $(INCLUDE_DIR)/package.mk
define Package/helloworld
SECTION:=utils
CATEGORY:=Utilities
TITLE:=Helloworld -- prints a snarky message
Package/PKG_NAME/description:=\
If you can't figure out what this program does, \\
you're probably brain-dead and need immediate \\
medical attention.
endef
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
$(CP) ./src/* $(PKG_BUILD_DIR)/
endef
define Package/helloworld/install
$(INSTALL_DIR) $(1)/bin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/helloworld $(1)/bin/
endef
$(eval $(call BuildPackage,helloworld))
之后我运行从sdk root
发出命令我收到以下错误
> naro_uClibc-0.9.33.2$ make V=s make[1]: Entering directory
> '/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2'
> make[2]: Entering directory
> '/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2'
> make[3]: Entering directory
> '/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/package/helloworld' CFLAGS="-O2 -pipe -march=i486 -fno-caller-saves -fhonour-copts
> -Wno-error=unused-but-set-variable -I/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/staging_dir/target-i386_uClibc-0.9.33.2/usr/include
> -I/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/staging_dir/target-i386_uClibc-0.9.33.2/include
> -I/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/staging_dir/toolchain-i386_gcc-4.6-linaro_uClibc-0.9.33.2/usr/include
> -I/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/staging_dir/toolchain-i386_gcc-4.6-linaro_uClibc-0.9.33.2/include " CXXFLAGS="-O2 -pipe -march=i486 -fno-caller-saves -fhonour-copts
> -Wno-error=unused-but-set-variable -I/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/staging_dir/target-i386_uClibc-0.9.33.2/usr/include
> -I/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/staging_dir/target-i386_uClibc-0.9.33.2/include
> -I/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/staging_dir/toolchain-i386_gcc-4.6-linaro_uClibc-0.9.33.2/usr/include
> -I/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/staging_dir/toolchain-i386_gcc-4.6-linaro_uClibc-0.9.33.2/include "
> LDFLAGS="-L/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/staging_dir/target-i386_uClibc-0.9.33.2/usr/lib
> -L/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/staging_dir/target-i386_uClibc-0.9.33.2/lib -L/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/staging_dir/toolchain-i386_gcc-4.6-linaro_uClibc-0.9.33.2/usr/lib -L/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/staging_dir/toolchain-i386_gcc-4.6-linaro_uClibc-0.9.33.2/lib " make -j1 -C
> /home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/build_dir/target-i386_uClibc-0.9.33.2/helloworld/.
> AR=i486-openwrt-linux-uclibc-ar AS="ccache_cc -c -O2 -pipe -march=i486
> -fno-caller-saves -fhonour-copts -Wno-error=unused-but-set-variable" LD=i486-openwrt-linux-uclibc-ld NM=i486-openwrt-linux-uclibc-nm
> CC="ccache_cc" GCC="ccache_cc" CXX="ccache_cxx"
> RANLIB=i486-openwrt-linux-uclibc-ranlib
> STRIP=i486-openwrt-linux-uclibc-strip
> OBJCOPY=i486-openwrt-linux-uclibc-objcopy
> OBJDUMP=i486-openwrt-linux-uclibc-objdump
> SIZE=i486-openwrt-linux-uclibc-size CROSS="i486-openwrt-linux-uclibc-"
> ARCH="i386" ; make[4]: Entering directory
> '/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/build_dir/target-i386_uClibc-0.9.33.2/helloworld'
> make[4]: *** Notargets specified and no makefile found. Stop.
> make[4]: Leaving directory
> '/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/build_dir/target-i386_uClibc-0.9.33.2/helloworld'
> Makefile:32: recipe for target
> '/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/build_dir/target-i386_uClibc-0.9.33.2/helloworld/.built'
> failed make[3]: ***
> [/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/build_dir/target-i386_uClibc-0.9.33.2/helloworld/.built]
> Error 2 make[3]: Leaving directory
> '/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/package/helloworld' package/Makefile:105: recipe for target 'package/helloworld/compile'
> failed make[2]: *** [package/helloworld/compile] Error 2 make[2]:
> Leaving directory
> '/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2'
> package/Makefile:101: recipe for target
> '/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/staging_dir/target-i386_uClibc-0.9.33.2/stamp/.package_compile' failed make[1]: ***
> [/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/staging_dir/target-i386_uClibc-0.9.33.2/stamp/.package_compile] Error 2 make[1]: Leaving directory
> '/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2'
> /home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/include/toplevel.mk:144:
> recipe for target 'world' failed make: *** [world] Error 2
谁能帮我找出错误是什么?
我也在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))