Where can I download the unstripped version of libusb?

We are developing an application based on the OpenWRT platform, which needs to be linked to the libusb-1.0 library.

When we directly try to link to the libusb-1.0.so file extracted from the ipk package, The linker reports an error (undefined reference).

We already know from here that the error is caused by the shared library in the ipk package has being stripped.

But the SDK we downloaded from here does not seem to contain any libusb related files.

So we want to know where to download the mipsel_24kc libusb-1.0.so library file that has not been stripped?

Thanks :slight_smile:

as said by core developer jow

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.

See https://openwrt.org/docs/guide-developer/using_the_sdk for the SDK and this https://openwrt.org/docs/guide-developer/helloworld/start for turning your application in a package

1 Like

Well, we finally went to the official website to download the libusb source code, compiled it into a static library, and linked it to our App.

It seems that this is the easiest way. We only need this App to run on some dedicated devices, and there is no need to generate a package for this.

Of course, the simplest and friendly way is: openwrt directly provides unstripped linkable versions for its libraries.

OpenWrt does not support third party build systems, if you use your own toolchain you are on your own.

2 Likes

As I said at the beginning, we use the official toolchain of OpenWRT: https://downloads.openwrt.org/releases/19.07.3/targets/ramips/mt7621/openwrt-sdk-19.07.3-ramips-mt7621_gcc-7.5.0_musl.Linux-x86_64.tar.xz

But this toolchain does not include libusb, so we have to compile a libusb that can be used for linking.

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.

hi bobafetthotmail

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.

Thanks :stuck_out_tongue_winking_eye:

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. :joy:

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. :joy: :joy: :joy:

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.

Yeah, you got the key point now.

We just expect that the official support mechanism like apt-get install libusb-1.0-0-dev or yum install libusb-devel-1.0.

I also believe that this is the mode that most linux developers are more familiar with. This is exactly why we made this post.

Of course, this is just a suggestion. In fact, our problem has been solved.

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

https://www.yoctoproject.org/
https://www.ptxdist.org/

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. :grinning:

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.

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