Programs are linked with libraries. You could link them all statically, in which case, there would be no libraries on the target device. But, that takes up an unnecessarily large amount of storage if you have more than two or three programs. So, you need to copy shared libraries from the toolchain to the staging directory. How do you know which libraries?
One option is to copy all of them since they must be of some use, otherwise they wouldn't exist! That is certainly logical and, if you are creating a platform to be used by others for a range of applications, that would be the correct approach. Be aware, though, that a full glibc
is quite large. In the case of a CrossTool-NG build of glibc
2.19, the space taken by /lib
and /usr/lib
is 33 MiB. Of course, you could cut down on that considerably by using uClibc or Musel libc
libraries.
Another option is to cherry pick only those libraries that you require, for which you need a means of discovering library dependencies...