软件集Software Collections


1、SCLphp

一、SCL是什么
node

SCL项目主页:https://www.softwarecollections.org/python

  SCL(Software Collections)可让你在同一个操做系统上安装和使用多个版本的软件,而不会影响整个系统的安装包。mysql

SCL为社区的如下需求而设计:linux

    建立和使用软件集合生产系统、概念验证系统、开发测试平台。SCL目前已经支持Fedora和RHEL(衍生版本如CentOS也包含在内)。c++

    SCL的建立就是为了给RHEL/CentOS用户提供一种以方便、安全地安装和使用应用程序和运行时环境的多个(并且多是更新的)版本的方式,同时避免把系统搞乱。与之相对的是第三方源,它们可能会在已安装的包之间引发冲突。sql


现有软件选集:shell

如今有如下软件选集可供CentOS 6.5或以上版本应用vim

Ruby 1.9.3 (ruby193)
Python 2.7 (python27)
Python 3.3 (python33)
PHP 5.4 (php54)
Perl 5.16.3 (perl516)
Node.js 0.10 (nodejs010)
MariaDB 5.5 (mariadb55)
MySQL 5.5 (mysql55)
PostgreSQL 9.2 (postgresql92)centos

更多的软件集可参看这里:https://www.softwarecollections.org/en/scls/


二、安装SCL

    在CentOS下使用 SCL,须要安装CentOS Software Collections。它是CentOS Extras软件库的一部份,并可经过如下指命进行安装

Centos 7:

[root@Node3 ~]# yum install centos-release-scl

Dependencies Resolved

===================================================================================================================================
 Package                                Arch                    Version                              Repository               Size
===================================================================================================================================
Installing:
 centos-release-scl                     noarch                  10:7-3.el6.centos                    extras                   12 k
Installing for dependencies:
 centos-release-scl-rh                  noarch                  2-3.el6.centos                       extras                   12 k

Transaction Summary
===================================================================================================================================
Install       2 Package(s)


[root@Node3 yum.repos.d]# rpm -ql centos-release-scl
/etc/pki/rpm-gpg
/etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo
/etc/yum.repos.d/CentOS-SCLo-scl.repo
/usr/share/doc/centos-release-scl/GPL


Centos 6:

[root@Python ~]# yum install centos-release-SCL

Dependencies Resolved

============================================================================================================================================================================================
 Package                                               Arch                                   Version                                          Repository                              Size
============================================================================================================================================================================================
Installing:
 centos-release-scl-rh                                 noarch                                 2-3.el6.centos                                   extras                                  12 k

Transaction Summary
============================================================================================================================================================================================
Install       1 Package(s)


[root@Python yum.repos.d]# rpm -ql centos-release-scl-rh
/etc/pki/rpm-gpg
/etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo
/etc/yum.repos.d/CentOS-SCLo-scl-rh.repo
/usr/share/doc/centos-release-scl-rh/GPL


注意:Centos6和Centos7的包名是区分大小写的!


2、SCL的设置及启用

一、要启用和运行SCL中的应用,你还须要安装下列包:

[root@Python ~]# yum install scl-utils scl-utils-build


二、SCL的设置及启用

SCL设置步骤很是简单

[root@Python ~]# scl --help
usage: scl <action> [<collection>...] <command>
   or: scl -l|--list [<collection>...]
   or: scl register <path>
   or: scl deregister <collection> [--force]

Options:
    -l, --list            list installed Software Collections or packages
                          that belong to them
    -h, --help            display this help and exit

Actions:
    enable                calls enable script from Software Collection
                          (enables a Software Collection)
    <SCL script name>     calls arbitrary script from a Software Collection

Use '-' as <command> to read the command from standard input.

启用一个已经安装的SCL包

    须要在每一个命令中使用scl命令显式启用它(即想在哪条命令中使用SCL中的包,就得经过scl命令执行该命令)

$ scl enable <scl-package-name> <command>

若是想在启用的包时执行多条命令,你能够像下面那样建立一个启用SCL的bash会话

$ scl enable <scl-package-name> bash



3、SCL使用实例:CentOS下安装高版本GCC

    有时编译须要用到4.8以上版本的GCC,因为CentOS源没有提供高版本的GCC rpm包,这时就不能经过yum方式安装。一般的解决方案就是经过编译安装高版本的GCC(须要很长时间)。

这里介绍一个更好用、更简单的方法来升级系统GCC。


查看旧版本的GCC相关包:

[root@Python ~]# rpm -qa|grep gcc
libgcc-4.4.7-18.el6.x86_64
gcc-4.4.7-18.el6.x86_64
gcc-c++-4.4.7-18.el6.x86_64
gcc-gfortran-4.4.7-18.el6.x86_64


安装GCC 5:

[root@Python ~]# yum list|grep devtoolset|grep gcc
Repository epel is listed more than once in the configuration
Repository epel-debuginfo is listed more than once in the configuration
Repository epel-source is listed more than once in the configuration
devtoolset-3-gcc.x86_64                    4.9.2-6.2.el6          centos-sclo-rh
devtoolset-3-gcc-c++.x86_64                4.9.2-6.2.el6          centos-sclo-rh
devtoolset-3-gcc-gfortran.x86_64           4.9.2-6.2.el6          centos-sclo-rh
devtoolset-3-gcc-plugin-devel.x86_64       4.9.2-6.2.el6          centos-sclo-rh
devtoolset-4-gcc.x86_64                    5.3.1-6.1.el6          centos-sclo-rh
devtoolset-4-gcc-c++.x86_64                5.3.1-6.1.el6          centos-sclo-rh
devtoolset-4-gcc-gdb-plugin.x86_64         5.3.1-6.1.el6          centos-sclo-rh
devtoolset-4-gcc-gfortran.x86_64           5.3.1-6.1.el6          centos-sclo-rh
devtoolset-4-gcc-plugin-devel.x86_64       5.3.1-6.1.el6          centos-sclo-rh
devtoolset-4-libgccjit.x86_64              5.3.1-6.1.el6          centos-sclo-rh
devtoolset-4-libgccjit-devel.x86_64        5.3.1-6.1.el6          centos-sclo-rh
devtoolset-4-libgccjit-docs.x86_64         5.3.1-6.1.el6          centos-sclo-rh
devtoolset-6-gcc.x86_64                    6.2.1-3.1.el6          centos-sclo-rh
devtoolset-6-gcc-c++.x86_64                6.2.1-3.1.el6          centos-sclo-rh
devtoolset-6-gcc-gdb-plugin.x86_64         6.2.1-3.1.el6          centos-sclo-rh
devtoolset-6-gcc-gfortran.x86_64           6.2.1-3.1.el6          centos-sclo-rh
devtoolset-6-gcc-plugin-devel.x86_64       6.2.1-3.1.el6          centos-sclo-rh
devtoolset-6-libgccjit.x86_64              6.2.1-3.1.el6          centos-sclo-rh
devtoolset-6-libgccjit-devel.x86_64        6.2.1-3.1.el6          centos-sclo-rh
devtoolset-6-libgccjit-docs.x86_64         6.2.1-3.1.el6          centos-sclo-rh

   在centos6.5上安装devtoolset-3会报错,4和6的版本不会。

[root@Python ~]# yum install devtoolset-4-gcc devtoolset-4-gcc-c++ devtoolset-4-gcc-gfortran


安装后:

[root@Python ~]# rpm -qa|grep gcc
devtoolset-4-gcc-5.3.1-6.1.el6.x86_64
libgcc-4.4.7-18.el6.x86_64
gcc-4.4.7-18.el6.x86_64
gcc-c++-4.4.7-18.el6.x86_64
devtoolset-4-gcc-c++-5.3.1-6.1.el6.x86_64
gcc-gfortran-4.4.7-18.el6.x86_64
devtoolset-4-gcc-gfortran-5.3.1-6.1.el6.x86_64


启用高版本的GCC:

[root@Python ~]# gcc --version
gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-18)
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[root@Python ~]# scl -l
devtoolset-4


启用SCL的方法:

1) scl enable 软件包名 bash   

     启用一个新的shell

[root@Python ~]# scl enable devtoolset-4 bash  # 进入一个新shell

[root@Python ~]# gcc --version
gcc (GCC) 5.3.1 20160406 (Red Hat 5.3.1-6)
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[root@Python ~]# c++ --version
c++ (GCC) 5.3.1 20160406 (Red Hat 5.3.1-6)
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[root@Python ~]# g++ --version
g++ (GCC) 5.3.1 20160406 (Red Hat 5.3.1-6)
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


2 )source /opt/rh/devtoolset-4/enable 

      在当前shell中生效

[root@Python ~]# source /opt/rh/devtoolset-4/enable 
[root@Python ~]# gcc --version
gcc (GCC) 5.3.1 20160406 (Red Hat 5.3.1-6)
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[root@Python ~]# c++ --version
c++ (GCC) 5.3.1 20160406 (Red Hat 5.3.1-6)
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[root@Python ~]# g++ --version
g++ (GCC) 5.3.1 20160406 (Red Hat 5.3.1-6)
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


若是咱们须要开机设置GCC 5:

[root@Python ~]# echo "source /opt/rh/devtoolset-4/enable" > /etc/profile.d/RK.sh


注意:

 经过devtoolset安装的gcc由于没有libstdc++包,没有生成libstdc++库文件,编译或运行程序时可能会遇到

  相似 /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found 的问题

[root@Python ~]# rpm -qa|grep libstdc++    # 没有devtoolset-4-libstdc包
libstdc++-4.4.7-18.el6.x86_64
libstdc++-devel-4.4.7-18.el6.x86_64
devtoolset-4-libstdc++-devel-5.3.1-6.1.el6.x86_64

[root@Python ~]# rpm -ql devtoolset-4-libstdc++-devel|grep libstdc++.so
[root@Python ~]# rpm -ql libstdc++-devel|grep libstdc++.so
[root@Python ~]# rpm -ql libstdc++|grep libstdc++.so
/usr/lib64/libstdc++.so.6
/usr/lib64/libstdc++.so.6.0.13
[root@Python ~]# ls -l `rpm -ql libstdc++|grep libstdc++.so`
lrwxrwxrwx 1 root root     19 Jun  7 06:46 /usr/lib64/libstdc++.so.6 -> libstdc++.so.6.0.13
-rwxr-xr-x 1 root root 987096 Mar 21 12:04 /usr/lib64/libstdc++.so.6.0.13

[root@Python ~]# find / -name "libstdc++*"
/root/libstdc++-5.3.1-6.fc22.x86_64.rpm
/opt/rh/devtoolset-4/root/usr/lib/gcc/x86_64-redhat-linux/5.3.1/libstdc++_nonshared.a
/opt/rh/devtoolset-4/root/usr/lib/gcc/x86_64-redhat-linux/5.3.1/libstdc++.so
/opt/rh/devtoolset-4/root/usr/lib/gcc/x86_64-redhat-linux/5.3.1/32/libstdc++_nonshared.a
/opt/rh/devtoolset-4/root/usr/lib/gcc/x86_64-redhat-linux/5.3.1/32/libstdc++.so
/opt/rh/devtoolset-4/root/usr/lib/gcc/x86_64-redhat-linux/5.3.1/32/libstdc++fs.a
/opt/rh/devtoolset-4/root/usr/lib/gcc/x86_64-redhat-linux/5.3.1/32/libstdc++.a
/opt/rh/devtoolset-4/root/usr/lib/gcc/x86_64-redhat-linux/5.3.1/libstdc++fs.a
/opt/rh/devtoolset-4/root/usr/lib/gcc/x86_64-redhat-linux/5.3.1/libstdc++.a
/usr/lib64/libstdc++.so.6
/usr/lib64/libstdc++.so.6.0.13
/usr/share/gdb/auto-load/usr/lib64/libstdc++.so.6.0.13-gdb.py
/usr/share/gdb/auto-load/usr/lib64/libstdc++.so.6.0.13-gdb.pyo
/usr/share/gdb/auto-load/usr/lib64/libstdc++.so.6.0.13-gdb.pyc
/usr/share/gdb/auto-load/usr/lib/libstdc++.so.6.0.13-gdb.py
/usr/share/gdb/auto-load/usr/lib/libstdc++.so.6.0.13-gdb.pyo
/usr/share/gdb/auto-load/usr/lib/libstdc++.so.6.0.13-gdb.pyc
/usr/share/doc/libstdc++-devel-4.4.7
/usr/lib/gcc/x86_64-redhat-linux/4.4.4/libstdc++.so
/usr/lib/gcc/x86_64-redhat-linux/4.4.4/32/libstdc++.so
/usr/lib/gcc/x86_64-redhat-linux/4.4.4/32/libstdc++.a
/usr/lib/gcc/x86_64-redhat-linux/4.4.4/libstdc++.a
/usr/lib/vmware-tools/lib64/libstdc++.so.6
/usr/lib/vmware-tools/lib64/libstdc++.so.6/libstdc++.so.6
/usr/lib/vmware-tools/lib32/libstdc++.so.6
/usr/lib/vmware-tools/lib32/libstdc++.so.6/libstdc++.so.6


# devtoolset安装的gcc仍是调用老的libstdc++动态库

[root@Python ~]# vim /opt/rh/devtoolset-4/root/usr/lib/gcc/x86_64-redhat-linux/5.3.1/libstdc++.so
[root@Python ~]# vim /opt/rh/devtoolset-4/root/usr/lib/gcc/x86_64-redhat-linux/5.3.1/32/libstdc++.so
[root@Python ~]# strings /opt/rh/devtoolset-4/root/usr/lib/gcc/x86_64-redhat-linux/5.3.1/32/libstdc++.so
/* GNU ld script
   Use the shared library, but some functions are only in
   the static library, so try that secondarily.  */
OUTPUT_FORMAT(elf32-i386)
INPUT ( /usr/lib/libstdc++.so.6 -lstdc++_nonshared )
[root@Python ~]# strings /opt/rh/devtoolset-4/root/usr/lib/gcc/x86_64-redhat-linux/5.3.1/libstdc++.so
/* GNU ld script
   Use the shared library, but some functions are only in
   the static library, so try that secondarily.  */
OUTPUT_FORMAT(elf64-x86-64)
INPUT ( /usr/lib64/libstdc++.so.6 -lstdc++_nonshared )


详见:http://xiexiaojun.blog.51cto.com/2305291/1934746

相关文章
相关标签/搜索