Reputation: 83
As we all know,gcc will search some default dir when compiling targets,
I use gcc -print-search-dirs
commnd and get this stuff:
install: /usr/lib/gcc/x86_64-redhat-linux/4.8.5/
programs: =/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/:/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/:/usr/libexec/gcc/x86_64-redhat-linux/:/usr/lib/gcc/x86_64-redhat-linux/4.8.5/:/usr/lib/gcc/x86_64-redhat-linux/:/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../x86_64-redhat-linux/bin/x86_64-redhat-linux/4.8.5/:/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../x86_64-redhat-linux/bin/
libraries: =/usr/lib/gcc/x86_64-redhat-linux/4.8.5/:/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../x86_64-redhat-linux/lib/x86_64-redhat-linux/4.8.5/:/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../x86_64-redhat-linux/lib/../lib64/:/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../x86_64-redhat-linux/4.8.5/:/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/:/lib/x86_64-redhat-linux/4.8.5/:/lib/../lib64/:/usr/lib/x86_64-redhat-linux/4.8.5/:/usr/lib/../lib64/:/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../x86_64-redhat-linux/lib/:/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../:/lib/:/usr/lib/
I have two questions about this:
What does /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../x86_64-redhat-linux/bin/
mean, and why write like that?
Why /usr/include
is not there?Doesn't gcc need to know where headfile is?
Upvotes: 5
Views: 3500
Reputation: 445
So as to question 1, I found this in the gcc mailing list:
Note that a/b/c/../../../x will only exist if a/b/c exists.
So your gcc will only search in /usr/x86_64-redhat-linux/bin/
if /usr/lib/gcc/x86_64-redhat-linux/4.8.5/
exists.
Note that I've got similar search-dirs on arch, and the /usr/x86_64-redhat-linux/
-equivalent ones don't exist, so I'm not sure WHY they are even included, but Linux has a notoriously unstandardized directory structure, so perhaps it's important for other distros.
Regarding 2, from the man page:
-print-search-dirs
Print the name of the configured installation directory and a list of program and library directories gcc searches---and don't do anything else. This is useful when gcc prints the error message installation problem, cannot exec cpp0: No such file or directory. To resolve this you either need to put cpp0 and the other compiler components where gcc expects to find them, or you can set the environment variable GCC_EXEC_PREFIX to the directory where you installed them. Don't forget the trailing /.
This seems to print not the library paths, but rather the paths where gcc expects to find the components it calls to do it's work.
To find the paths the preprocessor searches, type
`gcc -print-prog-name=cc1plus` -v
or
`gcc -print-prog-name=cc1` -v
for the C preprocessor.
Upvotes: 2