ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
When a GCC cross compiler is built, it creates the directories "<prefix>/<target>" and "<prefix>/lib/gcc/<target>". I see that target libraries seem to be installed there, and they are included in the search paths despite "--with-sysroot", "--with-native-system-header-dir", and "--with-lib-path" being in the configuration options. What exactly is it for (seems like it would make more sense to have target libs in the sysroot), and why is it apparently not customizable?
Like any tool, gcc can be installed anywhere. When you build cross-compiler versions, you probably have several related copies on hand. The directory structure is built in a certain way so that the various components of the system will know exactly where to look for things. Within its appointed "container," so to speak, the layout of things in that "container" is fixed.
But what doesn't make sense to me is that when --with-sysroot is given, shouldn't that be the "container"? The libraries will have to be found from there at runtime anyway, so it seems strange to have a different location where libraries that are incompatible with or unavailable on the target system can be installed.
The gcc compiler doesn't care about the layout of libraries and so-forth on the target system: it just needs to know about header-files and libraries that correspond to the target of choice so that it can correctly build for the target although it does not run on the target.
That makes some more sense, but what if I want to create a new sysroot, install libraries into it, and only use it as the source of libraries when compiling? I also don't understand how it should work with libraries other than those that are part of the gcc package.
There is also a build- sysroot . . . In both cases, these are specifically concerned with cross-compiling, where gcc runs in one environment but builds code for another.
I'm trying to create a compiler for a target system in a certain directory, but I don't understand why there isn't the option to look only in that directory, to prevent any possible conflicts or unwanted side effects. It doesn't make sense to me why it's designed to make it so diffucult to create a cross compiler and runtime libraries for a target system, and there's not really any documentation for it, when it seems like it should be such a basic and important thing.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.