[root@localhost /]# yum search gcc
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.neusoft.edu.cn
* updates: mirrors.nwsuaf.edu.cn
================================== N/S matched: gcc ===================================
gcc-c++.x86_64 : C++ support for GCC
gcc-gnat.x86_64 : Ada 95 support for GCC
gcc-objc.x86_64 : Objective-C support for GCC
gcc-objc++.x86_64 : Objective-C++ support for GCC
gcc-plugin-devel.x86_64 : Support for compiling GCC plugins
libgcc.x86_64 : GCC version 4.8 shared support library
libgcc.i686 : GCC version 4.8 shared support library
relaxngcc-javadoc.noarch : Javadoc for relaxngcc
compat-gcc-44.x86_64 : Compatibility GNU Compiler Collection
compat-gcc-44-c++.x86_64 : C++ support for compatibility compiler
compat-gcc-44-gfortran.x86_64 : Fortran support for compatibility compiler
gcc.x86_64 : Various compilers (C, C++, Objective-C, Java, ...)
gcc-gfortran.x86_64 : Fortran support
gcc-go.x86_64 : Go support
libgomp.x86_64 : GCC OpenMP v3.0 shared support library
libgomp.i686 : GCC OpenMP v3.0 shared support library
libmudflap.i686 : GCC mudflap shared support library
libmudflap.x86_64 : GCC mudflap shared support library
libmudflap-devel.i686 : GCC mudflap support
libmudflap-devel.x86_64 : GCC mudflap support
libquadmath.i686 : GCC __float128 shared support library
libquadmath.x86_64 : GCC __float128 shared support library
libquadmath-devel.i686 : GCC __float128 support
libquadmath-devel.x86_64 : GCC __float128 support
relaxngcc.noarch : RELAX NG Compiler Compiler
Name and description Search only, use the "search all" try.
[root@localhost /]# yum install gcc-c++ -y
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.neusoft.edu.cn
* updates: mirrors.nwsuaf.edu.cn
Dependencies are resolved
-> Checking Services
---> Package gcc-c ++. X86_64.0.4.8.5-28.el7_5.1 will be installed
-> Processing dependency libstdc ++ - devel = 4.8.5-28.el7_5.1, it is the package gcc-c ++ - 4.8.5-28.el7_5.1.x86_64 need
-> Processing dependence libstdc ++ = 4.8.5-28.el7_5.1, it is the package gcc-c ++ - 4.8.5-28.el7_5.1.x86_64 need
-> Processing dependence gcc = 4.8.5-28.el7_5.1, it is the package gcc-c ++ - 4.8.5-28.el7_5.1.x86_64 need
-> Processing dependence libmpc.so.3 (64bit) (), which is a package gcc-c ++ - 4.8.5-28.el7_5.1.x86_64 need
-> Checking Services
---> packages will be installed gcc.x86_64.0.4.8.5-28.el7_5.1
-> Processing dependence libgomp = 4.8.5-28.el7_5.1, it needs to be a package gcc-4.8.5-28.el7_5.1.x86_64
-> Processing dependence cpp = 4.8.5-28.el7_5.1, it needs to be a package gcc-4.8.5-28.el7_5.1.x86_64
-> Processing dependence libgcc> = 4.8.5-28.el7_5.1, it needs to be a package gcc-4.8.5-28.el7_5.1.x86_64
-> Processing Dependencies glibc-devel> = 2.2.90-12, it needs to be a package gcc-4.8.5-28.el7_5.1.x86_64
---> packages will be installed libmpc.x86_64.0.1.0.1-3.el7
---> Package libstdc ++. X86_64.0.4.8.5-16.el7 will be upgraded
---> Package libstdc ++. X86_64.0.4.8.5-28.el7_5.1 will be updated
---> Package libstdc ++ - devel.x86_64.0.4.8.5-28.el7_5.1 will be installed
-> Checking Services
---> packages will be installed cpp.x86_64.0.4.8.5-28.el7_5.1
---> Package glibc-devel.x86_64.0.2.17-222.el7 will be installed
-> Processing Dependencies glibc-headers = 2.17-222.el7, it is the package glibc-devel-2.17-222.el7.x86_64 need
-> Processing Dependencies glibc = 2.17-222.el7, it is the package glibc-devel-2.17-222.el7.x86_64 need
-> Processing Dependencies glibc-headers, which is the package glibc-devel-2.17-222.el7.x86_64 need
---> packages will be upgraded libgcc.x86_64.0.4.8.5-16.el7
---> packages will be updated libgcc.x86_64.0.4.8.5-28.el7_5.1
---> packages will be upgraded libgomp.x86_64.0.4.8.5-16.el7
---> packages will be updated libgomp.x86_64.0.4.8.5-28.el7_5.1
-> Checking Services
---> packages will be upgraded glibc.x86_64.0.2.17-196.el7
-> Processing Dependencies glibc = 2.17-196.el7, it is the package glibc-common-2.17-196.el7.x86_64 need
---> packages will be updated glibc.x86_64.0.2.17-222.el7
---> Package glibc-headers.x86_64.0.2.17-222.el7 will be installed
-> Processing dependencies kernel-headers> = 2.2.1, it is the package glibc-headers-2.17-222.el7.x86_64 need
-> Processing dependencies kernel-headers, which is the package glibc-headers-2.17-222.el7.x86_64 need
-> Checking Services
---> packages will be upgraded glibc-common.x86_64.0.2.17-196.el7
---> Package will be updated glibc-common.x86_64.0.2.17-222.el7
---> Package kernel-headers.x86_64.0.3.10.0-862.14.4.el7 will be installed
-> resolve dependencies completed
Resolve dependencies
=======================================================================================
Package size version of the source architecture
=======================================================================================
Installing:
gcc-c++ x86_64 4.8.5-28.el7_5.1 updates 7.2 M
The installation is dependent on:
cpp x86_64 4.8.5-28.el7_5.1 updates 5.9 M
gcc x86_64 4.8.5-28.el7_5.1 updates 16 M
glibc-devel x86_64 2.17-222.el7 base 1.1 M
glibc-headers x86_64 2.17-222.el7 base 678 k
kernel-headers x86_64 3.10.0-862.14.4.el7 updates 7.1 M
libmpc x86_64 1.0.1-3.el7 base 51 k
libstdc++-devel x86_64 4.8.5-28.el7_5.1 updates 1.5 M
To rely updated:
glibc x86_64 2.17-222.el7 base 3.6 M
glibc-common x86_64 2.17-222.el7 base 11 M
libgcc x86_64 4.8.5-28.el7_5.1 updates 101 k
libgomp x86_64 4.8.5-28.el7_5.1 updates 156 k
libstdc++ x86_64 4.8.5-28.el7_5.1 updates 303 k
Transaction Summary
=======================================================================================
Mounting a package (package dependent +7)
Upgrade (5 dependent packages)
Total downloads: 55 M
Downloading packages:
No Presto metadata available for base
Not downloading deltainfo for updates, MD is 679 k and rpms are 560 k
Warning: /var/cache/yum/x86_64/7/base/packages/glibc-2.17-222.el7.x86_64.rpm: head V3 RSA / SHA256 Signature, Key ID f4a80eb5: NOKEY
glibc-2.17-222.el7.x86_64.rpm public key is not already installed
(1/13): glibc-2.17-222.el7.x86_64.rpm | 3.6 MB 00:00:30
gcc-c ++ - 4.8.5-28.el7_5.1.x86_64.rpm public key has not been installed] 371 kB / s | 18 MB 00:01:42 ETA
(2/13): gcc-c++-4.8.5-28.el7_5.1.x86_64.rpm | 7.2 MB 00:00:50
(3/13): glibc-headers-2.17-222.el7.x86_64.rpm | 678 kB 00:00:07
(4/13): glibc-common-2.17-222.el7.x86_64.rpm | 11 MB 00:01:16
(5/13): libgcc-4.8.5-28.el7_5.1.x86_64.rpm | 101 kB 00:00:12
(6/13): libgomp-4.8.5-28.el7_5.1.x86_64.rpm | 156 kB 00:00:02
(7/13): glibc-devel-2.17-222.el7.x86_64.rpm | 1.1 MB 00:01:04
(8/13): cpp-4.8.5-28.el7_5.1.x86_64.rpm | 5.9 MB 00:01:36
(9/13): libstdc++-4.8.5-28.el7_5.1.x86_64.rpm | 303 kB 00:00:03
(10/13): libstdc++-devel-4.8.5-28.el7_5.1.x86_64.rpm | 1.5 MB 00:00:08
libmpc-1.0.1-3.el7.x86_64.rpm FAILED :28 ETA
http://centos.ustc.edu.cn/centos/7.5.1804/os/x86_64/Packages/libmpc-1.0.1-3.el7.x86_64.rpm: [Errno 12] Timeout on http://centos.ustc.edu.cn/centos/7.5.1804/os/x86_64/Packages/libmpc-1.0.1-3.el7.x86_64.rpm: (28, 'Operation too slow. Less than 1000 bytes/sec transferred the last 30 seconds')
Others are trying to mirror.
(11/13): libmpc-1.0.1-3.el7.x86_64.rpm | 51 kB 00:00:04
(12/13): gcc-4.8.5-28.el7_5.1.x86_64.rpm | 16 MB 00:02:20
(13/13): kernel-headers-3.10.0-862.14.4.el7.x86_64.rpm | 7.1 MB 00:01:38
---------------------------------------------------------------------------------------
A total of 361 kB / s | 55 MB 02:37
From file: /// etc / pki / rpm-gpg / RPM-GPG-KEY-CentOS-7 retrieval key
Import GPG key 0xF4A80EB5:
用户ID : "CentOS-7 Key (CentOS 7 Official Signing Key) <[email protected]>"
Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
Package: centos-release-7-4.1708.el7.centos.x86_64 (@anaconda)
From: / etc / pki / rpm-gpg / RPM-GPG-KEY-CentOS-7
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Updating: libgcc-4.8.5-28.el7_5.1.x86_64 1/18
Updating: glibc-common-2.17-222.el7.x86_64 2/18
Updating: glibc-2.17-222.el7.x86_64 3/18
Installing: libmpc-1.0.1-3.el7.x86_64 4/18
Updating: libstdc ++ - 4.8.5-28.el7_5.1.x86_64 5/18
Installing: libstdc ++ - devel-4.8.5-28.el7_5.1.x86_64 6/18
Installing: cpp-4.8.5-28.el7_5.1.x86_64 7/18
Updating: libgomp-4.8.5-28.el7_5.1.x86_64 8/18
Installing: kernel-headers-3.10.0-862.14.4.el7.x86_64 9/18
Being installed: glibc-headers-2.17-222.el7.x86_64 10/18
Being installed: glibc-devel-2.17-222.el7.x86_64 11/18
Installing: gcc-4.8.5-28.el7_5.1.x86_64 12/18
Installing: gcc-c ++ - 4.8.5-28.el7_5.1.x86_64 13/18
Cleanup: libstdc ++ - 4.8.5-16.el7.x86_64 14/18
Cleanup: libgomp-4.8.5-16.el7.x86_64 15/18
Cleanup: glibc-common-2.17-196.el7.x86_64 16/18
Cleanup: glibc-2.17-196.el7.x86_64 17/18
Cleanup: libgcc-4.8.5-16.el7.x86_64 18/18
Verification: libgomp-4.8.5-28.el7_5.1.x86_64 1/18
Verification: libgcc-4.8.5-28.el7_5.1.x86_64 2/18
Verification: libstdc ++ - devel-4.8.5-28.el7_5.1.x86_64 3/18
Verification: gcc-4.8.5-28.el7_5.1.x86_64 4/18
Verification: glibc-devel-2.17-222.el7.x86_64 5/18
Verification: cpp-4.8.5-28.el7_5.1.x86_64 6/18
Verification: glibc-headers-2.17-222.el7.x86_64 7/18
Verification: kernel-headers-3.10.0-862.14.4.el7.x86_64 8/18
Verification: libmpc-1.0.1-3.el7.x86_64 9/18
Verification: glibc-common-2.17-222.el7.x86_64 10/18
Verification: libstdc ++ - 4.8.5-28.el7_5.1.x86_64 11/18
Verification: glibc-2.17-222.el7.x86_64 12/18
Verification: gcc-c ++ - 4.8.5-28.el7_5.1.x86_64 13/18
Verification: libgcc-4.8.5-16.el7.x86_64 14/18
Verification: libstdc ++ - 4.8.5-16.el7.x86_64 15/18
Verification: glibc-common-2.17-196.el7.x86_64 16/18
Verification: glibc-2.17-196.el7.x86_64 17/18
Verification: libgomp-4.8.5-16.el7.x86_64 18/18
Installed:
gcc-c++.x86_64 0:4.8.5-28.el7_5.1
It is selected as a dependency:
cpp.x86_64 0: 4.8.5-28.el7_5.1 gcc.x86_64 0: 4.8.5-28.el7_5.1
glibc-devel.x86_64 0:2.17-222.el7 glibc-headers.x86_64 0:2.17-222.el7
kernel-headers.x86_64 0:3.10.0-862.14.4.el7 libmpc.x86_64 0:1.0.1-3.el7
libstdc++-devel.x86_64 0:4.8.5-28.el7_5.1
Be upgraded as a dependency:
glibc.x86_64 0:2.17-222.el7 glibc-common.x86_64 0:2.17-222.el7
libgcc.x86_64 0: 4.8.5-28.el7_5.1 libgomp.x86_64 0: 4.8.5-28.el7_5.1
libstdc++.x86_64 0:4.8.5-28.el7_5.1
Finished!
[root@localhost /]# g++ -v
Use the built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/lto-wrapper
Goal: x86_64-redhat-linux
配置为:../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/cloog-install --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.8.5 20150623 (Red Hat 4.8.5-28) (GCC)
[root@localhost /]# ls
bin dev home lib64 mnt pause.png root sbin sys usr
boot etc lib media opt proc run srv tmp var
[root@localhost /]# cd home
[root@localhost home]# ls
xqx
[root@localhost home]# mkdir c++
[root@localhost home]# cd c++
[root@localhost c++]# ls
[root@localhost c++]# touch test.cpp
[root@localhost c++]# vim test.cpp
#include<iostream>
int main(int argc,char * argv[])
{
std::cout<<"running\n";
return 0;
}
[Root @ localhost c ++] # g ++ -Wall test.cpp -o test Description: -Wall -o displays a warning message is output into an executable file
[Root @ localhost c ++] # chmod u + x test only granted permission to this document belongs to those who executed
[Root @ localhost c ++] # ./test run the resulting executable test
running
[root@localhost c++]# ls -l
Total amount 16
-rwxr-xr-x. 1 root root 8968 11月 1 00:09 test
-rw-r--r--. 1 root root 94 11月 1 00:08 test.cpp
[root@localhost c++]#