本篇内容介绍了“怎么创建openwrt软件包”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!
make menuconfig选上“Build the OpenWRT SDK”,然后 Save,退出。再make一次。
make 完成之后,在 bin/ramips/ 目录下会生成SDK的压缩文件:
OpenWrt-SDK-ramips-rt305x_gcc-4.8-linaro_uClibc-0.9.33.2.Linux-x86_64.tar.bz2
把上面生成的OpenWrt-SDK-ramips-rt305x_gcc-4.8-linaro_uClibc-0.9.33.2.Linux-x86_64.tar.bz2解压到别的目录下
其实,这里可以是任意我们想要加入的程序,库等。这里就以helloword为例。
在任意路径下,创建helloword项目。比如这里还是在 ~/Workspace/OpeWRT 目录下。
$ cd ~/Workspace/OpenWRT
$ mkdir helloword
$ cd helloword
$ touch helloword.c Makefile
在 ~/Workspace/OpenWRT/ 目录下创建了 helloword 目录,并生成 helloword.c与Makefile文件。
如下为 helloworld.c的内容:
#include <stdio.h>
int main()
{
printf("This is my hello word!\n");
return 0;
}
Makefile的内容:
helloworld : helloworld.o
$(CC) $(LDFLAGS) helloworld.o -o helloworld
helloworld.o : helloworld.c
$(CC) $(CFLAGS) -c helloworld.c
clean :
rm *.o helloworld
自己make一下确保程序没有问题,一定要注意tab键空格。
进入 OpenWrt/Packages/ 并在该目录下创建 helloworld 目录,并进入该目录。
$ cd ~/Workspace/OpenWrt/OpenWrt-SDK/package
$ mkdir helloworld
$ cd helloworld
将我们第三步写的程序复制到这个目录下来,更名为src。再新建一个 Makefile 文件。
$ cp -r ../../../helloworld src
$ touch Makefile
整个过程下来,package目录结构如下:
package
|-- helloworld
| |-- Makefile
| `-- src
| |-- helloworld.c
| `-- Makefile
`-- Makefile
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:=Hello world!!!
DEPENDS:=+libwebsockets +libsqlite3 +libjson-c
endef
define Package/helloworld/description
It's my first package demo.
endef
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
$(CP) ./src/* $(PKG_BUILD_DIR)/
endef
define Package/helloworld/install
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/$(PKG_NAME) $(1)/usr/sbin
endef
$(eval $(call BuildPackage,helloworld))
make -j1 V=s 成功了。生成了 helloworld_1_ramips_24kec.ipk。
通过WinSCP把ipk上能到openwrt根目录下的/tmp
cd /tmp
opkg install helloworld_1_ramips_24kec.ipk
用which命令查看 helloworld 安装的路径:
which helloworld
在 /bin/ 路径下
cd /bin
helloworld
把方法一创建helloworld文件夹复制到openwrt根目录下的package。
make menuconfig
Utilities——》helloworld勾选上并保存退出
make -j3 V=s
如果要单独编译模块:
make package/helloworld/compile
make package/helloworld/install
cd /bin
helloworld
把新helloworld文件替换旧hellworld文件
重新编译
make package/helloworld/compile
在openwrt目录的./build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/helloworld/ipkg-ramips_24kec/helloworld/bin下找到重新生成的helloworld文件,重新替换路由器/bin下面的helloworld。
“怎么创建openwrt软件包”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注亿速云网站,小编将为大家输出更多高质量的实用文章!
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。
原文链接:https://my.oschina.net/u/1759641/blog/543207