openwrt编译软件包

openwrt--编译单个软件包 Openwrt 对单个软件包编译 阅读详情

1、搭建openwrt环境,创建sdk

这个步骤可以不需要,可直接在http://downloads.openwrt.org/上download官方的sdk,但可能会出现编译问题

搭建过程见http://blog.youkuaiyun.com/wonengxing/article/details/8703658


2、 新建自己的packages
对于自己新建的package,而这个package又不需要随固件一起安装,换句话说,就是可以当做一个可选软件包的话。我们可以利用我们的SDK环境来单独编译,编译后会生成一个ipk的文件包。然后利用 opkg install xxx.ipk 来安装这个软件。

下面具体说下,如何编译一个helloword的软件包。
(1)首先,编写helloworld程序
编写helloworld.c
/****************
* Helloworld.c
* The most simplistic C program ever written.
* An epileptic monkey on crack could write this code.
*****************/

#include <stdio.h>
#include <unistd.h>
int main(void)
{
     printf("Hell! O' world, why won't my code compile?\n\n");
     return 0;
}

编写Makefile文件
# build helloworld executable when user executes "make"

helloworld: helloworld.o
$(CC) $(LDFLAGS) helloworld.o -o helloworld

helloworld.o: helloworld.c
$(CC) $(CFLAGS) -c helloworld.c

# remove object files and executable when user executes "make clean"
clean:
rm *.o helloworld
                                  
在这两个文件的目录下,执行make 应该可以生成helloworld的可执行文件。执行helloworld后,能够打印出“Hell! O' world, why won't my code compile?”。 这一步,主要保证我们的源程序是可以正常编译的。下面我们将其移植到OpenWRT上。

(2)将OpenWrt-SDK-ar71xx-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2.tar.bz2解压
tar –xvf OpenWrt-SDK-ar71xx-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2.tar.bz2

(3)进入SDK
cd OpenWrt-SDK-ar71xx-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2
可以看到里面的目录结构跟我们之前source的目录结构基本相同,所需要编译的软件包,需要放置在package目录下

(4)在package目录下创建helloworld目录
cd package
mkdir helloworld
cd helloworld

(5)创建src目录,拷贝 helloworld文件
mkdir src
cp /home/wrt/test/helloworld.c src
cp /home/wrt/test/Makefile src

(6)在helloworld目录下创建Makefile文件
这个Makefile文件是给OpenWRT读的,而之前写的那个Makefile文件是针对helloworld给编译其读的。两个Makefile不在同一层目录下。

touch Makefile
vim Makefile

Makefile文件模板内容如下:
##############################################
# OpenWrt Makefile for helloworld program
#
#
# Most of the variables used here are defined in
# the include directives below. We just need to
# specify a basic description of the package,
# where to build our program, where to find
# the source files, and where to install the
# compiled program on the router.
#
# Be very careful of spacing in this file.
# Indents should be tabs, not spaces, and
# there should be no trailing whitespace in
# lines that are not commented.
#
##############################################

include $(TOPDIR)/rules.mk

# Name and release number of this package
PKG_NAME:=helloworld
PKG_RELEASE:=1


# 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)/package.mk

 

# Specify package information for this program.
# The variables defined here should be self explanatory.
# If you are running Kamikaze, delete the DESCRIPTION
# variable below and uncomment the Kamikaze define
# directive for the description below
define Package/helloworld
SECTION:=utils
CATEGORY:=Utilities
TITLE:=Helloworld -- prints a snarky message
endef


# Uncomment portion below for Kamikaze and delete DESCRIPTION variable above
define Package/helloworld/description
If you can't figure out what this program does, you're probably
brain-dead and need immediate medical attention.
endef

 

# Specify what needs to be done to prepare for building the package.
# In our case, we need to copy the source files to the build directory.
# This is NOT the default.  The default uses the PKG_SOURCE_URL and the
# PKG_SOURCE which is not defined here to download the source from the web.
# In order to just build a simple program that we have just written, it is
# much easier to do it this way.
define Build/Prepare
        mkdir -p $(PKG_BUILD_DIR)
        $(CP) ./src/* $(PKG_BUILD_DIR)/
endef


# We do not need to define Build/Configure or Build/Compile directives
# The defaults are appropriate for compiling a simple program such as this one


# Specify where and how to install the program. Since we only have one file,
# the helloworld executable, install it by copying it to the /bin directory on
# the router. The $(1) variable represents the root directory on the router running
# OpenWrt. The $(INSTALL_DIR) variable contains a command to prepare the install
# directory if it does not already exist.  Likewise $(INSTALL_BIN) contains the
# command to copy the binary file from its current location (in our case the build
# directory) to the install directory.
define Package/helloworld/install
$(INSTALL_DIR) $(1)/bin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/helloworld $(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)返回到SDK的根目录
执行make进行编译
编译过程会在build_dir目录下完成
编译结果会放在 bin/[yourtarget]/package目录下helloworld_1_ar71xx.ipk

(8)上传helloworld_1_ar71xx.ipk
使用sftp软件上传helloworld_1_ar71xx.ipk至路由器
执行 opkg install helloworld_1_ar71xx.ipk
输入hello然后按Tab键,发现openwrt中已经有helloworld可执行命令。
执行 helloworld 查看程序的效果。

Hell! O' world, why won't my code compile?


注意:所有Makefile文件中前面有空的地方是tab不是空格,否则编译出错。


转自:http://hi.baidu.com/gouooo/item/6932bfa97d23d1981410736a

OpenWrt编译自己的应用程序 编译OpenWrt的应用程序可以参考OpenWrt内部其他应用程序的例程,来编写成自己的应用程序。 阅读详情

相关推荐

openwrt软件包 1: 如何为自己的软件包编写makefile,并将其编译到镜像中

写篇一生之敌Makefile

yoga的博客 3327

工业网关开发:Openwrt系统开发流程

本篇介绍了如何从官方开源网站,如何一步一步来搭建自己网关产品的嵌入式Linux系统,如何开发安装业务app以及定制后台web控制界面。

十六宿舍的博客 5633

1-OpenWrt编译过程-2

本文是 OpenWrt 编译的后半部分,本章会结合具体的编译操作来分析编译过程。

weixin_43882328的博客 3095

openwrt软件包 4: 如何在一个Makefile中编译多个软件包

通过一个Makefile编译多个软件包

yoga的博客 1211

openwrt修复编译中feeds软件包丢失问题

1.卸载单个软件包 ./scripts/feeds uninstall luci 2.安装单个软件包 ./scripts/feeds install luci 3.更新及安装所有软件包 ./scripts/feeds update -a ./scripts/feeds install -a

wgl307293845的博客 2458

编译官方原版的openwrt并加入第三方软件包

本文旨在记录编译官方openwrt的一些过程,并加入第三方软件包,仅供参考。

li 2万+

OpenWrt编译软件包

在虚拟机上搭建好OpenWrt环境,具体可见我的另一篇文章《OpenWrt环境搭建和编译过程》 我这边以编译Snort (NIDS) 为例,列出编译软件包的步骤。 1、进入到OpenWrt主目录。 2、输入如下命令: $ make menuconfig 3、进入到配置界面,找到路径 Network->Firewall->snort,按y选定,并保存退出。若不知道需要安装的包在什么路径,...

有理论,有实验,有结论,可为一篇文章 6902

如何在openwrt下编译ipsec隧道相关软件包并配置隧道

查看ipsec隧道日志 logread | grep ipsecswanctl --log #启动连接(需要选择二阶段名) swanctl --initiate --child hz # 清理连接(需要选择一阶段名) swanctl --terminate --ike HZ 3 .查看隧道已启动的连接swanctl -l 4 .查看配置是否有问题附件:附自己编译的openwrt固件,包含ipsec隧道软件包。

qq_33744128的博客 2081

Openwrt:创建编译IPK软件包

一、概述 openwrt 一个比较重要的特点就是它采用 ipk 包的形式安装软件。有点像是 windows 下面的安装包一样,用户只需用简单的命令就可以将 ipk 安装包安装到 openwrt 系统中,非常方便。 ipk包 ...

Jags的博客 1万+

MMI分束器仿真优化:用Lumerical FDTD实现95%耦合效率的实战技巧

本文详细介绍了使用Lumerical FDTD软件对MMI分束器进行仿真优化的实战技巧。通过构建高保真模型、精确配置光源与边界条件,并重点优化波导结构与taper设计,系统性地将器件的耦合效率提升至95%以上。文章还分享了利用参数扫描、varFDTD加速等高级方法,帮助硅光芯片设计工程师高效实现高性能MMI分束器设计。

rainy的博客 769

GEE开发之ERA5(气温、降水、压力、风速等)数据获取和分析

前言:ERA5主要提供DAILY和MONTHLY两大类别数据,其中主要包括气温、降水、压力、风速等。

等待着冬天的风的博客 3万+

OpenWrt软件包的编译

由http://blog.youkuaiyun.com/zahuopuboss/article/details/18825515知道每个目录下的Makefile中都会有11个目标规则 分别为SUBTARGETS:=clean download prepare compile install update refresh prereq dist distcheck configure 每个软件包下的

雜貨鋪 1224

NX二次开发入门必看:手把手教你搭建开发环境

想顺利开展nx二次开发,第一步就是配置好开发环境。本文详细讲解从安装准备到环境调试的完整流程,结合实际操作细节,帮你避开常见坑点,快速进入nx二次开发的实战阶段。

weixin_31569663的博客 1456

【OpenWrt】如何单独编译packages软件包

官网说明:https://downloads.openwrt.org/kamikaze/docs/openwrt.html 2.1.5 Troubleshooting If you find your package doesn’t show up in menuconfig, try the following command to see if you get the correct desc

BoyeMaker 1万+

DQN网络代码调用env.reset()后存储观测信息报错问题ValueError: setting an array element with a sequence.解决处理

**reset()函数返回的是一个array类型以及其中数据的type!模拟游戏进行学习任务。因此需要将observation指定为真正需要的array信息即可,得到的的变量observation类型与Agent存储时的。因此怀疑返回的observation有问题,于是通过。报错信息提示为数据维度不对应,也即最初通过。在强化学习DQN网络代码实现过程中,针对。

Vulcan_Q的博客 4092

SAP 实例解析分期付款配置及应用

SAP系统的付款条件支持分期付款功能,其奥妙之处就在于需要定义一个母条款和一个子条款,其中,母条款需要标识“分期付款”。 首先,定义分期付款的母条款OBB8:             然后,定义子条款(即分期付款的具体方式)OBB9:   由上图可以看出,分期付款的配置还是很强大的,针对每次付款,都可以进行第二层次付款条件的设置。   然后,我们做一笔发票,

heng0757的专栏 1万+

openwrt编译-提升下载第三方软件包速度的方法

    编译openwrt系统时,对于选择的第三方软件包,会通过脚本(curl方法)去下载软件压缩包到dl目录中。  但是这个过程呢,因为网站网速限制,导致下载速度特别的慢,经常会出现下载失败导致编译停止的情况。之前我的做法是,编译中时不时关注编译log信息,如果出现软件包下载特别慢的情况,会自己手动下载软件包并放置在dl目录。  这里提供两个网址,上面提供了相当全的软件包,openwrt编译需要的基本都能找到。  https://sources.openwrt.or

ziguayungui的专栏 3921

一种独特机理驱动的化学反应分类器详解

代码位置第 47-300+ 行// atom_494: 硫原子,度数=2,化合价=2,无H,无电荷!// atom_35: 氧原子,度数=1,1个H,无电荷// atom_347: 氧原子,度数=2,无H,无电荷!→atom_494()[OD1h1+0]→atom_35()→atom_347()特性传统方法(MCS)NameRXN(机理驱动)匹配策略最大公共子结构原子类型模式 + 操作码时间复杂度O(n) - 线性扫描机理理解无内置化学机理原子映射需额外计算自动推导准确性结构相似。

ASKCOS博客 156

推荐开源项目:Action OpenWrt IPKs - 自动化编译OpenWrt软件包利器

推荐开源项目:Action OpenWrt IPKs - 自动化编译OpenWrt软件包利器 项目介绍 Action OpenWrt IPKs 是一个巧妙利用 GitHub Actions 实现的自动化工具,它能每天检查OpenWrt x86-64 源码更新,并自动编译出含有完整依赖的ipk软件包。这个项目旨在简化OpenWrt爱好者们的日常维护与升级操作,让你轻松获取最新鲜的软件资源。 项目技术...

gitblog_00049的博客 514

大模型部署指南:SGLang 框架

本文介绍使用 SGLang 框架部署大模型

举世誉之而不加劝,举世非之而不加沮,定乎内外之分,辩乎荣辱之境,斯已矣。 1610

【调优】OpenClaw从零开始高阶调优之skill篇

本文详细解析了OpenClaw技能系统的核心机制。首先介绍了技能的分层加载逻辑,按照优先级从高到低依次为:工作区专属技能、全局共享技能、出厂自带技能和自定义路径技能。通过流程图展示了从扫描到注册的完整加载流程,并解释了同名技能覆盖规则。随后深入剖析了SKILL.md文件结构,包含YAML元数据定义技能属性和Markdown正文说明使用方法,以公众号写作技能为例展示了具体配置。文章还提供了技能优先级切换的实用技巧,帮助用户灵活管理不同版本的技能。

海兰 238

openwrt 遍译php_openwrt sdk编译软件包笔记

前言:这个周末在研究怎么在openwrt运行一个pppoe服务器。过程可谓曲折...上次玩openwrt已经是12.09的版本,这次已经是15.05.1了,编译时又遇到新的错误提示。所以做了下笔记 ,省得又忘记。openwrt编译一个软件包。下载sdk下来。解压到目录。之后在目录下运行./script/feed update #下载软件包的索引./script/feed install rp-pp...

weixin_39868959的博客 347

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

OpenWrt学习总结(2)编译OpenWrt过程中整理的软件包下载网址

编译OpenWrt BarrierBreaker14.07过程中会出现很多软件包找不到软件源,或者连接不到软件包的下载网址,这时我们就需要根据编译出现的错误提示去手动下载相应的软件包。 手动下载时,建议使用Google搜索,百度搜不到GitHub上的资源 OpenWrt官方的软件源(提供的软件包较新,有的软件包找不到) https://downloads.openwrt.org/so

xiaomingtongxie的博客 4123

锂电池充电器电路设计 里面有电路

锂电池充电器电路设计 里面有电路 3.7V升压到5V电路设计。

IMSL CNL 7.0.0 (x86-64)Crack

IMSL CNL 7.0.0 (x86-64)Crack intel的算法库破解文件,这是C++版本的破解文件

OpenWrt 编译 | 一种使用 git submodule 方式实现一键更新多个外部软件包

本文将详细介绍一种使用 git submodule 子仓库的方式实现在编译 OpenWrt' 时一键更新多个外部软件包的方法。

TeleostNaCl的博客 601

老版QQ原生表情gif动态

这是老版的QQ表情,不过全是动态的的,Windows照片查看器是不会动的,可以右击用浏览器打开查看,再说一遍是老版的,只是分享给宁愿用老版也要动态的人。

【调试笔记-20240528-Linux-用 OpenWrt-23.05 SDK 编译 frp 软件包】

本文记录在 Linux 环境下用 OpenWrt-23.05 SDK 编译运行 frp 软件包的步骤。实验使用的电脑如下:本文介绍了在 Linux 环境下用 OpenWrt-23.05 SDK 编译运行 frp 软件包的步骤,并指出过程中遇到的问题及解决方法。

David唐辉的博客 1443
上一篇: debian6编译openwrt过程
下一篇: openwrt中horst的编译问题
骑行的蜗牛
博客等级 码龄21年 107粉丝 86原创
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值