Is the boot box available in a shared library form?

Is the boot box available in a shared library form? I would like to use separate applications programmatically instead of using system() . I heard about libbusybox and libbb but did not find any documentation.

+6
c linux
source share
2 answers

There is a busybox library in general form called libbusybox(.so) , you just need to enable it when creating menuconfig. When you compile it will be available in the 0_lib folder. In this library, you have a small function called int lbb_main(char **argv) .

What you need to do in your code is something like this:

 extern int lbb_main(char **argv); int main() { char* strarray[] = {"ifconfig",0}; lbb_main(strarray); return 1; } 

You can import libb.h , but this did not work for me, because I got a lot of errors.

After that, you just need to compile using something like gcc -o code code.c -Lpath_to_0_lib_fodler -lbusybox and what it is!

In order to intercept the output, you will have to redefine printf and similar calls, but this can clearly be done using soemthing macros such as #define printf(...) code' in libb.h'.

You can even create a busybox wrapper that doesn't use fork or the system, but that doesn't work yet.

+6
source share

If you are in a tiny embedded system where it matters, you can link your application to the busybox binary, then you can call its functions without any dynamic linker at all.

If you do not, just use system () or some combination of fork / exec.

It is unlikely that you will often want to call utilities, which matters performance.

0
source share

All Articles