You either need to build libusb as well on device or use the OpenWrt SDK to properly cross compile your application using the unstripped staging libraries.
So you must create a package for your application so the OpenWrt build system (or the SDK) can link it to the libusb.
No you are not. You download that archive just to extract a library, and then use your own toolchhain to compile your application. You also tried linking directly to a compiled library package too.
Also what you did for static compiling, you took the library from upstream and you put in your own toolchain and you used that to build your application.
That is not how you use OpenWrt toolchain.
Using the official toolchain of OpenWrt means that every application you make is prepared like a package as I said above.
That allows to actually use the OpenWrt's own toolchain or SDK. When you give the command to compile your package to the toolchain/SDK it will download your package's dependency libraries source, compile them and then do the compiling and linking of your package.
The SDK package does not contain sources or linkable libraries for anything, it will download them when required during the build process of the package.
I found you totally immersed in your own imagination. In fact, we have been using the official toolchain a few years ago. Just because the author of this post (sky59) mentioned:
So in order to reconfirm, we downloaded the toolchain again on another machine and searched for it, but we still did not find libusb.
This does not affect the machine we used to perform cross-compilation, which has been using the official toolchain for many years, OK?
In this post, we also never said that we are not using the official toolchain. I believe we know better than you which toolchain we are using.
As I said already, the toolchain downloads the source and compiles the library only if required by a package or if you ask it to compile libusb package. The SDK only contains pre-compiled host toolchain (gcc and whatnot), not all the possible libs your package may need.
If you download from download server and open it there is no libusb library. This is normal.
The other person in the other thread probably has already used the SDK to compile some package that needs libusb so it has downloaded and compiled the libusb library in his system.
I believe we know better than you which toolchain we are using.
How do you use the official toolchain to build an application that is not a package as said here?
We only need this App to run on some dedicated devices, and there is no need to generate a package for this.
The only way the toolchain works to compile applications and link them with libraries is if they are defined as a package and define dependencies.
Since you said you don't make a package, then you are not using the toolchain for this package.
calling gcc manually from the toolchain folders does not count, because as you also noticed when you need to integrate with libraries nothing works.
I am glad that we finally reached an agreement on the fact that we are indeed using the official toolchain.
The way we use the official toolchain of OpenWRT is the same as using other toolchains, such as linaro or Ubuntu’s toolchain.
What we expect is a convenient mechanism similar to apt-get install libusb-1.0-0-dev that allows us to add new libraries to the toolchain.
But for now, there is no such convenient method for OpenWRT.
Because our projects are managed by graphical IDEs such as CodeBlocks, creating a package to resolve dependencies is more troublesome for us than downloading libusb and compiling it ourselves.
So we still use the official toolchain to compile libusb by ourselves.
Yeah you are "using" it like you can use a screwdriver as a hammer. What you are doing is not supported.
What you did is ok for a quick hack, but firmware size will increase a lot if many packages are compiled statically like that.
Writing a single makefile with 20 lines of text (that is all is needed to create a package with OpenWrt build system) is not hard and can be done from inside your graphical IDE too.
Having your program built as a package is more convenient, because you can now use other OpenWrt build tools to integrate it in a firmware image, install or update it in a device with the package manager, and so on.
From what you say, you are not very familiar with opensource projects, and you expect them to work like a vendor SDK, but that is not how they usually work.
Doing that would mean the toolchain is limited to a specific Ubuntu or RHEL version, and porting it over to a new version will be a pain. This is not a problem for a vendor SDK because they never update anything.
While OpenWrt build system is designed to build nearly everything it needs from scratch so there is no more that problem.
This was a choice, to be independent from third party distros.
Many other opensource projects use a similar independent build system that rebuilds everything from scratch and ignores host libraries
Then I would like to ask you who are familiar with open source projects, do you need to use instructions like apt-get install libusb-1.0-0-dev or yum install libusb-devel-1.0 to install dependencies library when developing products on Ubuntu or CentOS?
Or do you have a "more suitable way for open source projects" in Ubuntu or CentOS to install your dependent libraries?
Or on the other hand, why can't OpenWRT provide a very convenient one-line command to solve the problem like Ubuntu or CentOS? It has nothing to do with whether it is open source or not. Ubuntu and OpenWRT are both open source platforms.
Although the project we are porting to OpenWRT is not large, it also has 155 C/C++ compilation units, and has been ported to 21 target platforms including Windows, Linux, Macintosh, Android, etc. And various hardware platforms such as x86, mips, arm, power, etc.
We are not aware of any trouble with this way of installing dependent libraries with just one line of instructions. It only takes less than a minute. Even if you download the libusb source code and compile it from scratch, it only takes about 20 minutes. On the contrary, I want to learn the package rules of OpenWRT from scratch and write the appropriate makefile for our project. It takes at least several hours of work.
Maybe you have spent a lot of time learning these rules and you will find that this is also good. But other popular Linux distributions such as Ubuntu, which are also open source platforms, only need one instruction to do this.
Maybe you are interested and have time to learn more about OpenWRT's package configuration rules. But I think most developers, at least at the beginning of getting started with a new platform, just want to complete their work in the simplest, direct and convenient way.
Discussing this issue has wasted too much time for both of us, I think we can stop here. Thank you very much for your comments.
OpenWrt could, if it would only target devices with >> 1 GB main storage and >=512 MB RAM - as long as most supported devices remain far below those specs, size is king.