linux下openwrt安装教程视频,创建openwrt软件包

方法一

1、生成SDK

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

2、安装SDK

把上面生成的OpenWrt-SDK-ramips-rt305x_gcc-4.8-linaro_uClibc-0.9.33.2.Linux-x86_64.tar.bz2解压到别的目录下

3、创建helloworld项目

其实,这里可以是任意我们想要加入的程序,库等。这里就以helloword为例。

在任意路径下,创建helloword项目。比如这里还是在 ~/Workspace/OpeWRT 目录下。

$ cd ~/Workspace/OpenWRT

$ mkdir helloword

$ cd helloword

$ touch helloword.c Makefile

在 ~/Workspace/OpenWRT/ 目录下创建了 helloword 目录,并生成 helloword.c与Makefile文件。

如下为 helloworld.c的内容:

#include

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键空格。

4、创建helloworld包

进入 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。

5、试验helloworld

通过WinSCP把ipk上能到openwrt根目录下的/tmp

cd /tmp

opkg install helloworld_1_ramips_24kec.ipk

用which命令查看 helloworld 安装的路径:

which helloworld

在 /bin/ 路径下

cd /bin

helloworld

方法二

1、创建helloworld项目

把方法一创建helloworld文件夹复制到openwrt根目录下的package。

2、选择helloworld项目

make menuconfig

Utilities——》helloworld勾选上并保存退出

make -j3 V=s

如果要单独编译模块:

make package/helloworld/compile

make package/helloworld/install

3、试验helloworld

cd /bin

helloworld

4、后续开发

把新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。

上面的内容本人是参照网上文档并自己实践过。

Ubuntu下架设FTP服务器实现Windows、openwrt、ubuntu互传文件:http://www.linuxdiyf.com/linux/13394.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值