I'm using a Bootlin aarch64 toolchain to cross-compile some C++ code. I notice that I can compile just fine simply calling the compiler without any special flags. Specifically, I can compile without passing the --sysroot flag. I can see that the compiler has been configured with the --with-sysroot option:
--with-sysroot=/opt/aarch64--glibc--stable-2020.08-1/aarch64-buildroot-linux-gnu/sysroot
However, I don't have the compiler placed in that location, so I'd expect it to not know what sysroot to use.
I can also see the default system include list that it uses, and all paths are correctly calculated, relative to the location of the compiler. So it will use the headers from the toolchain instead of the standard ones at /usr/include and so on.
Therefore my question is: do I need to use --sysroot here? What problem would it solve? Or put differently - what problems can I run into if I don't pass that flag in this case?
To put it simple, it's to allow you to build projects that may require additional dependencies, but without creating a mess.
For example, let's say you have to use library libasdf.so in your project. You build that library, after you've done this, you won't be able to use it, since your project doesn't know how to find it. Sure, you can specify to look for it in some specific path, but what if you have a dozen of libraries to use? That would be inconvinient, and create a mess of flags.
That's why you install these libraries into your sysroot, now you can have access to any library your system is supposed to have as if it was installed on your main system.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With