在ubuntu上用eclipse来编译的C文件,然后生成bin文件放在openwrt的机器上运行
想使用c语言来调用uci的一些接口来实现读取和修改配置的工作
ubuntu上安装uci
参考:https://blog.csdn.net/rainforest_c/article/details/70142987
C语言调用uci的说明
参考:https://blog.csdn.net/bytxl/article/details/43761573
https://blog.csdn.net/junglefly/article/details/52415978
然后在eclipse里面编译的时候各种报错
1、提醒uci.h找不到,然后参考:https://blog.csdn.net/x13163303344/article/details/79182787
添加了路径,错误解决;
2、 if (UCI_OK != uci_load(ctx, UCI_CONFIG_FILE, &pkg)) 这句报错
应该是UCI_CONFIG_FILE没有定义,参考这个:#define UCI_CONFDIR "/etc/config",做了对应的路径定义
3、
- xxx.c:(.text+0x1f8): undefined reference to `uci_alloc_context'
- xxx.c:(.text+0x210): undefined reference to `uci_lookup_ptr'
- xxx.c:(.text+0x228): undefined reference to `uci_perror'
- xxx.c:(.text+0x270): undefined reference to `uci_free_context
搜到这个文章解决的:https://blog.csdn.net/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
不知道是哪里的问题。
二个说是因为权限问题,我还在想办法尝试看是不是这个问题