LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-20-2016, 10:11 PM   #1
testtext
LQ Newbie
 
Registered: Jun 2016
Posts: 6

Rep: Reputation: Disabled
Explanation of GCC directory structure


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?
 
Old 07-21-2016, 07:32 AM   #2
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941
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.
 
1 members found this post helpful.
Old 07-22-2016, 01:06 AM   #3
testtext
LQ Newbie
 
Registered: Jun 2016
Posts: 6

Original Poster
Rep: Reputation: Disabled
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.
 
Old 07-22-2016, 08:06 AM   #4
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941
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.
 
1 members found this post helpful.
Old 07-22-2016, 02:12 PM   #5
testtext
LQ Newbie
 
Registered: Jun 2016
Posts: 6

Original Poster
Rep: Reputation: Disabled
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.
 
Old 07-23-2016, 07:50 AM   #6
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941
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.
 
Old 07-23-2016, 11:30 AM   #7
testtext
LQ Newbie
 
Registered: Jun 2016
Posts: 6

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by sundialsvcs View Post
There is also a build- sysroot
Doesn't that only affect the libraries used by the cross-compiler itself (not the code that it compiles)?

Quote:
Originally Posted by sundialsvcs View Post
In both cases, these are specifically concerned with cross-compiling, where gcc runs in one environment but builds code for another.
That's the whole point of this question...
 
Old 07-26-2016, 09:10 PM   #8
testtext
LQ Newbie
 
Registered: Jun 2016
Posts: 6

Original Poster
Rep: Reputation: Disabled
Nobody knows the answer?

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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Modify the directory entry structure of a directory to show manipulated data shreyas08 Linux - Newbie 1 12-13-2011 05:34 AM
how to disable structure alignment using gcc compiler options ? aryan1 Programming 3 01-26-2010 08:21 AM
Convert directory structure from long file names in Linux to DOS 8.3 structure? manorina Linux - Software 5 09-12-2009 09:18 AM
Home Jail Folder Structure like Gobolinux Directory Structure luispt Linux - General 3 07-26-2008 06:46 PM
"WARNING: Circular directory structure" error when deleting directory pistonbrew Linux - Software 5 02-03-2005 06:05 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:37 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration