I am compiling gcc and reading manual from https://gcc.gnu.org/install/configure.html
it spcifies
--with-local-prefix=dirname Specify the installation directory for local include files. The default is /usr/local. Specify this option if you want the compiler to search directory dirname/include for locally installed header files instead of /usr/local/include.
I take this to mean that when compiling other binaries with this version of GCC it will check this director before the default /usr/.../
directoris?
--with-sysroot=dir Tells GCC to consider dir as the root of a tree that contains (a subset of) the root filesystem of the target operating system. Target system headers, libraries and run-time object files will be searched for in there. More specifically, this acts as if --sysroot=dir was added to the default options of the built compiler. If you specify the --with-native-system-header-dir=dirname option then the compiler will search that directory within dirname for native system headers rather than the default /usr/include.
To compile GCC 5.4.0 I yum install gcc gcc-c++
(ie 4.8.0) and this places headers such as stdio.h
in /usr/include/
. After I have complied GCC 5.4.0 and specify it to complie anther binary, the 5.4.0 seems to use the 4.8.0 headers in /usr/include/
instead of the ones created during the 5.4.0 compile.
What I am really asking is, if I want to compile GCC (5.4.0) and have the make install
install headers as well as GCC & G++ etc in to a custom folder, what options do I set? is my configure for compiling GCC 5.4.0 correct?
/home/myuser/gcc-5.4.0/configure --prefix=/home/gcc540 --disable-multilib --with-system-zlib --enable-languages=c,c++ --with-local-prefix=/home/myotherbin/local --with-gxx-include-dir=/home/gcc540/header
--prefix=/home/gcc540
set master directory make install
--prefix=/home/gcc540/bin
make install
will install binaries (gcc, g++ etc)--prefix=/home/gcc540/lib
make install
will install libs--with-gxx-include-dir=/home/gcc540/headers
make install
will install headers for --enable-languages=c,c++
--with-local-prefix=/home/otherprogs
(libs,headers from other dependencies are searched here first) ie this is where I would put x264 headers if I was compiling ffmpegso what goes in --with-sysroot=dir
||--with-native-system-header-dir=dirn
?
Additionally, after I have exported to --with-gxx-include-dir=/home/gcc540/headers
I have tr1/stdio.h
that includes the following code,
#include <tr1/cstdio>
this causes an error as both stdio.h
and cstdio
are in the same folder, should stdio.h
be copied to the parent folder, or is best practice just to pass both -I/home/gcc540/headers
-I/home/gcc540/headers/tr1` to gcc 5.4.0?
The --with-sysroot
option is only useful when you build a cross-compiler : the resulting, built gcc will know where to find the target platform's headers and libraries (i.e. it will have a default value for the --sysroot option). The --with-native-system-header-dir
is a refinement of the --with-sysroot
option and allows to specify a directory relative to the one specified for --with-sysroot
where native platform headers will be found. GCC distinguishes its own headers (the ones it copies as part of make install
) from the "native" headers that are provided by the operating system itself and were already there regardless of the GCC install.
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