Header Files for building a package in OpenWrt

I want to use uci.h and iwlib.h in building a package for openwrt .
I followed this https://openwrt.org/docs/guide-developer/helloworld/start link to start the process and i can build simple files using other headers available in staging_dir/toolchain-mipsel_24kc_gcc-7.5.0_musl/include/
but i cannot find header files for uci.h and iw.h anywhere in the source directory. If i need to add these header files where do i add them ?

What do i need to do to build packages using these header files ?

I am going to rewrite this script in C and I join to this question.

According to the Makefile the library was compiled from HP repository, so the iwlib.h might be took from there as well.

Hello I am looking to build a simple application that uses iwlib.h API rather than system calls to the iw commands. What might be a path that i can take ?
I guess in the make menuconfig there is a libraries menu which contains libiw which i am guessing is a archive(.a) file but i cannot find where that is stored and how can i access the iwlib.h api to create a package i am a bit confused on that .

This is the simple package i am trying to build which parses the output of iw wlan0 survey dump and find the best channel to change using some algorithm. The algorithm is basic and wont be used in a real scenario but i am trying to learn the process on how to use this. How can i include all the functionalities of iwlib.h?
Sorry if i am asking simple questions but i am new to package development.

I am guessing the https://github.com/openwrt/openwrt/blob/openwrt-19.07/package/network/utils/wireless-tools/Makefile here is trying to call the source code from the location https://hewlettpackard.github.io/wireless-tools and using the dynamic library . I will look into the makefiles in more details.

Yeah, I think I came across the same problem:

root@OpenWrt:~/meshwhtlst# gcc -liw wifi-scan.c 
/usr/bin/ld: cannot find -liw
collect2: error: ld returned 1 exit status

First you have to create the Makefile in your project, but it is not a trivial task and you have to look for examples.
Second you have to add your feeding directory with your package to the feeds.conf according to this manual.

So, I am a new in C and can't be an advisor for you in this situation. But, I have a temptation to use fopen instead of library.

As far as I understood, you only need to install libiw29 with opkg and then add files iwlib.h and wireless.h to your project...

That's wrong link, there is a right link

Hmm yes i have also been using the system calls instead of library but these will i guess add a lot of overhead for the code.
The code here is actually really simple and i can build my package with this code also but i am guessing i am missing something here regarding makefiles which is not allowing me to include the iwlib.h and other libraries and functionalities other than standard linux headers like stdlib.h and stdio.h.
So this code works in the openwrt using the toolchain as per the link
https://openwrt.org/docs/guide-developer/helloworld/chapter3 but for additional api's i am having issues.

There is a project where I used an external header in my project (UTHASH). But it is not a library, it's just an additional header.

And there is an example how I made a package for OpenWrt.

So, I have tried to compile an example in OpenWrt environment and got fail:

root@OpenWrt:~/# gcc -liw wifi-scan.c 
/usr/bin/ld: cannot find -liw
collect2: error: ld returned 1 exit status
root@OpenWrt:~/# ln -s /usr/lib/libiw.so.29 /usr/lib/libiw.so
root@OpenWrt:~/# gcc -liw wifi-scan.c 
/tmp/ccoIHIan.o: In function `main':
wifi-scan.c:(.text+0xc): undefined reference to `iw_sockets_open'
wifi-scan.c:(.text+0x25): undefined reference to `iw_get_range_info'
wifi-scan.c:(.text+0x5a): undefined reference to `iw_scan'
collect2: error: ld returned 1 exit status
root@OpenWrt:~/# ls -l
-rw-r--r--    1 root     root         16857 Jan 12 13:11 iwlib.h
-rw-r--r--    1 root     root           913 Jan 12 13:13 wifi-scan.c
drwxr-xr-x    4 root     root          4096 Jan 12 13:10 wireless-tools
-rw-r--r--    1 root     root         43635 Jan 12 13:15 wireless.h

no ideas...

Hello I found the problem. (solved)
The actual problem for the toolchain was that i did not put DEPENDS:= in the mainfest file
For eg. as i am using iwlib.h which calls the library libiw i need to add the libiw in the DEPENDS of the manifest file
For eg: DEPENDS:= +libiw
what actually happens is the toolchain downloads all the required files and compiles the libiw for the target if i add DEPENDS.

Also in the makefile for the package i need to add -liw to the end of make command to denote that i am using the package libiw (.so) file .

This topic was automatically closed 0 minutes after the last reply. New replies are no longer allowed.