openwrt c语言使用uci

在ubuntu上用eclipse来编译的C文件,然后生成bin文件放在openwrt的机器上运行

想使用c语言来调用uci的一些接口来实现读取和修改配置的工作

ubuntu上安装uci

参考:https://blog.youkuaiyun.com/rainforest_c/article/details/70142987

C语言调用uci的说明

参考:https://blog.youkuaiyun.com/bytxl/article/details/43761573

https://blog.youkuaiyun.com/junglefly/article/details/52415978


然后在eclipse里面编译的时候各种报错

1、提醒uci.h找不到,然后参考:https://blog.youkuaiyun.com/x13163303344/article/details/79182787

添加了路径,错误解决;

2、  if (UCI_OK != uci_load(ctx, UCI_CONFIG_FILE, &pkg))  这句报错

应该是UCI_CONFIG_FILE没有定义,参考这个:#define UCI_CONFDIR "/etc/config",做了对应的路径定义

3、

  1. xxx.c:(.text+0x1f8): undefined reference to `uci_alloc_context'
  2. xxx.c:(.text+0x210): undefined reference to `uci_lookup_ptr'
  3. xxx.c:(.text+0x228): undefined reference to `uci_perror'
  4. xxx.c:(.text+0x270): undefined reference to `uci_free_context

搜到这个文章解决的:https://blog.youkuaiyun.com/flexman09/article/details/51546277

这个问题现在还没解决,搜索后说是2方面的问题

一个是在makefile里面加-luci,这个因为是用的eclipse开发,搜索后在这个里面做了修改

Press Project --> Properties --> C/C++ build --> Settings --> GCC C++ Linker --> 

Libraries --> in the "Libraries(-l)" box press the "+" sign --> write "dl" (without the quotes)-> press ok --> clean & rebuild your project.

结果是报了mipsel-openwrt-linux-uclibc/bin/ld: cannot find -luci

不知道是哪里的问题。

二个说是因为权限问题,我还在想办法尝试看是不是这个问题

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值