安装先前安装在其他文件夹中的编译程序

安装先前安装在其他文件夹中的编译程序

我在特定文件夹中编译gcc和依赖项(gmpmpfrmpc),以在其他文件夹中备份这些文件夹,而不重复编译过程,并传递到另一台机器。

制作仅用于更新

$ tar zxvf make-4.2.1.tar.gz -C /usr/local/Sources/
$ cd /usr/local/Sources/make-4.2.1/
$ ./configure --prefix=/usr/local/Custom/make
$ sh ./build.sh
$ ./make check
$ sudo ./make install

GCC 的依赖项

良好生产规范

$ tar Jxvf gmp-6.1.2.tar.xz -C /usr/local/Sources/
$ cd /usr/local/Sources/gmp-6.1.2/
$ ./configure --prefix=/usr/local/Custom/gmp --enable-cxx --disable-static
$ make
$ sudo make install

MPFR

$ tar -zxvf mpfr-3.1.6.tar.gz -C /usr/local/Sources/
$ ./configure --prefix=/usr/local/Custom/mpfr --disable-static --enable-thread-safe --with-gmp=/usr/local/Custom/gmp
$ make
$ sudo make install

多点控制

$ tar -zxvf mpc-1.0.3.tar.gz -C /usr/local/Sources/
$ cd /usr/local/Sources/mpc-1.0.3/
$ ./configure --prefix=/usr/local/Custom/mpc --with-gmp=/usr/local/Custom/gmp -with-mpfr=/usr/local/Custom/mpfr
$ make
$ make check
$ sudo make install

http://www.linuxfromscratch.org/blfs/view/cvs/general/gcc.html

海湾合作委员会

$ tar zxvf gcc-7.2.0.tar.gz -C /usr/local/Sources/
$ cd /usr/local/Sources/gcc-7.2.0/
$ ./configure --prefix=/usr/local/Custom/gcc --with-system-zlib --disable-multilib --enable-lenguages=c,c++ --with-gmp=/usr/local/Custom/gmp -with-mpfr=/usr/local/Custom/mpfr --with-mpc=/usr/local/Custom/mpc
$ time make -j $(nproc)

所花费的时间是超过8小时

real    506m8.644s
user    461m46.399s
sys 30m54.429s
$ 

$ time sudo make install

所花费的时间是

real    1m52.495s
user    0m35.449s
sys 0m35.820s
$ 

现在的层次结构是:

$ tree -d /usr/local/Custom/
/usr/local/Custom/
├── gcc
│   ├── bin
│   ├── include
│   │   └── c++
│   │       └── 7.2.0
│   │           ├── backward
│   │           ├── bits
│   │           ├── debug
│   │           ├── decimal
│   │           ├── experimental
│   │           │   └── bits
│   │           ├── ext
│   │           │   └── pb_ds
│   │           │       └── detail
│   │           │           ├── REMOVED IN ORDER TO MAKE SHORT THIS QUESTION
│   │           ├── parallel
│   │           ├── profile
│   │           │   └── impl
│   │           ├── tr1
│   │           ├── tr2
│   │           └── x86_64-pc-linux-gnu
│   │               ├── bits
│   │               └── ext
│   ├── lib
│   │   └── gcc
│   │       └── x86_64-pc-linux-gnu
│   │           └── 7.2.0
│   │               ├── REMOVED IN ORDER TO MAKE SHORT THIS QUESTION
│   ├── lib64
│   ├── libexec
│   │   └── gcc
│   │       └── x86_64-pc-linux-gnu
│   │           └── 7.2.0
│   │               ├── install-tools
│   │               └── plugin
│   └── share
│       ├── gcc-7.2.0
│       │   └── python
│       │       └── libstdcxx
│       │           └── v6
│       ├── info
│       ├── locale
│       │   ├── REMOVED IN ORDER TO MAKE SHORT THIS QUESTION
│       └── man
│           ├── man1
│           └── man7
├── gmp
│   ├── include
│   ├── lib
│   └── share
│       └── info
├── make
│   ├── bin
│   ├── include
│   └── share
│       ├── info
│       ├── locale
│       │   ├── REMOVED IN ORDER TO MAKE SHORT THIS QUESTION
│       └── man
│           └── man1
├── mpc
│   ├── include
│   ├── lib
│   └── share
│       └── info
├── mpfr
│   ├── include
│   ├── lib
│   └── share
│       ├── doc
│       │   └── mpfr
│       │       └── examples
│       └── info

现在,在命运机器中Original locations是:

$ whereis gmp mpfr mpc
gmp: /usr/include/gmp.h
mpfr: /usr/include/mpfr.h
mpc: /usr/include/mpc.h
$ which make gcc
/usr/local/bin/make
/usr/bin/gcc
$ 

问题

如何使用这些文件夹更新(makegmpmpfrmpcgcc其他计算机?

  • 替换旧命令(在其中Original locations)?
  • 保留旧命令(在另一个文件夹中,例如/my/Folder/Commands:)?

答案1

不适合LD_LIBRARY_PATH

$ more /etc/environment 
PATH=/usr/local/Custom/make/bin:/usr/local/Custom/gcc/bin:/usr/lib64/qt-3.3/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin
CPATH=/usr/local/Custom/make/include:/usr/local/Custom/gmp/include:/usr/local/Custom/mpfr/include:/usr/local/Custom/mpc/include
LD_LIBRARY_PATH=/usr/local/Custom/gmp/lib:/usr/local/Custom/mpfr/lib:/usr/local/Custom/mpc/lib
$

root与用户一起尝试

$ more /root/.bash_profile 
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
    . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin

export PATH

LD_LIBRARY_PATH=/usr/local/Custom/gmp/lib:/usr/local/Custom/mpfr/lib:/usr/local/Custom/mpc/lib
export LD_LIBRARY_PATH
$

在这两种情况下我得到:

$ echo $LD_LIBRARY_PATH

$

这是我的解决方案lib

$ more /etc/ld.so.conf.d/custom.conf
/usr/local/Custom/gmp/lib
/usr/local/Custom/mpfr/lib
/usr/local/Custom/mpc/lib

这是我的解决方案includebin

$ more /etc/environment 
PATH=/usr/local/Custom/make/bin:/usr/local/Custom/gcc/bin:/usr/lib64/qt-3.3/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/
sbin:/bin:/sbin
CPATH=/usr/local/Custom/make/include:/usr/local/Custom/gmp/include:/usr/local/Custom/mpfr/include:/usr/local/Custom/mpc/include
$ 

现在我检查:

$ which make gcc
/usr/local/Custom/make/bin/make
/usr/local/Custom/gcc/bin/gcc
$

$  cpp -v
Using built-in specs.
COLLECT_GCC=cpp
Target: x86_64-pc-linux-gnu
Configured with: ./configure --prefix=/usr/local/Custom/gcc --with-system-zlib --disable-multilib --enable-lenguages=c,c++ --with-gmp=/usr/local/Custom/gmp -with-mpfr=/usr/local/Custom/mpfr --with-mpc=/usr/local/Custom/mpc
Thread model: posix
gcc version 7.2.0 (GCC) 
COLLECT_GCC_OPTIONS='-E' '-v' '-mtune=generic' '-march=x86-64'
 /usr/local/Custom/gcc/libexec/gcc/x86_64-pc-linux-gnu/7.2.0/cc1 -E -quiet -v - -mtune=generic -march=x86-64
ignoring nonexistent directory "/usr/local/Custom/gcc/lib/gcc/x86_64-pc-linux-gnu/7.2.0/../../../../x86_64-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/Custom/make/include
 /usr/local/Custom/gmp/include
 /usr/local/Custom/mpfr/include
 /usr/local/Custom/mpc/include
 /usr/local/Custom/gcc/lib/gcc/x86_64-pc-linux-gnu/7.2.0/include
 /usr/local/include
 /usr/local/Custom/gcc/include
 /usr/local/Custom/gcc/lib/gcc/x86_64-pc-linux-gnu/7.2.0/include-fixed
 /usr/include
End of search list.

不幸的是我得到:

$ whereis gmp mpfr mpc
gmp:mpfr:mpc:[ ~]$ 

相关内容