CentOS搭建C++开发环境

先安装gcc;需要root权限;

切换到root用户;命令:sudo su;再输入密码;

切换到root用户;命令:yum install gcc;安装失败;

带 -y 再运行;安装成功;过程如下;gcc -v,查看版本;

[root@localhost /]# yum -y install gcc
Loaded plugins: fastestmirror, langpacks
base                                                     | 3.6 kB     00:00     
extras                                                   | 2.9 kB     00:00     
updates                                                  | 2.9 kB     00:00     
(1/3): base/7/x86_64/group_gz                              | 165 kB   00:01     
(2/3): extras/7/x86_64/primary_db                          | 164 kB   00:01     
(3/3): base/7/x86_64/primary_db                            | 6.0 MB   00:11     
Determining fastest mirrors
 * base: mirrors.163.com
 * extras: mirrors.cqu.edu.cn
 * updates: mirrors.cqu.edu.cn
Resolving Dependencies
--> Running transaction check
---> Package gcc.x86_64 0:4.8.5-39.el7 will be installed
--> Processing Dependency: libgomp = 4.8.5-39.el7 for package: gcc-4.8.5-39.el7.x86_64
--> Processing Dependency: cpp = 4.8.5-39.el7 for package: gcc-4.8.5-39.el7.x86_64
--> Processing Dependency: libgcc >= 4.8.5-39.el7 for package: gcc-4.8.5-39.el7.x86_64
--> Processing Dependency: libmpc.so.3()(64bit) for package: gcc-4.8.5-39.el7.x86_64
--> Running transaction check
---> Package cpp.x86_64 0:4.8.5-39.el7 will be installed
---> Package libgcc.x86_64 0:4.8.2-16.el7 will be updated
---> Package libgcc.x86_64 0:4.8.5-39.el7 will be an update
---> Package libgomp.x86_64 0:4.8.2-16.el7 will be updated
---> Package libgomp.x86_64 0:4.8.5-39.el7 will be an update
---> Package libmpc.x86_64 0:1.0.1-3.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package           Arch             Version                Repository      Size
================================================================================
Installing:
 gcc               x86_64           4.8.5-39.el7           base            16 M
Installing for dependencies:
 cpp               x86_64           4.8.5-39.el7           base           5.9 M
 libmpc            x86_64           1.0.1-3.el7            base            51 k
Updating for dependencies:
 libgcc            x86_64           4.8.5-39.el7           base           102 k
 libgomp           x86_64           4.8.5-39.el7           base           158 k

Transaction Summary
================================================================================
Install  1 Package  (+2 Dependent packages)
Upgrade             ( 2 Dependent packages)

Total download size: 22 M
Downloading packages:
No Presto metadata available for base
warning: /var/cache/yum/x86_64/7/base/packages/libgcc-4.8.5-39.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Public key for libgcc-4.8.5-39.el7.x86_64.rpm is not installed
(1/5): libgcc-4.8.5-39.el7.x86_64.rpm                      | 102 kB   00:00     
(2/5): libmpc-1.0.1-3.el7.x86_64.rpm                       |  51 kB   00:01     
(3/5): libgomp-4.8.5-39.el7.x86_64.rpm                     | 158 kB   00:01     
(4/5): cpp-4.8.5-39.el7.x86_64.rpm                         | 5.9 MB   00:21     
(5/5): gcc-4.8.5-39.el7.x86_64.rpm                         |  16 MB   00:33     
--------------------------------------------------------------------------------
Total                                              679 kB/s |  22 MB  00:33     
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Importing GPG key 0xF4A80EB5:
 Userid     : "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-0.1406.el7.centos.2.3.x86_64 (@anaconda)
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : libmpc-1.0.1-3.el7.x86_64                                    1/7 
  Installing : cpp-4.8.5-39.el7.x86_64                                      2/7 
  Updating   : libgomp-4.8.5-39.el7.x86_64                                  3/7 
  Updating   : libgcc-4.8.5-39.el7.x86_64                                   4/7 
  Installing : gcc-4.8.5-39.el7.x86_64                                      5/7 
  Cleanup    : libgomp-4.8.2-16.el7.x86_64                                  6/7 
  Cleanup    : libgcc-4.8.2-16.el7.x86_64                                   7/7 
  Verifying  : libgcc-4.8.5-39.el7.x86_64                                   1/7 
  Verifying  : libgomp-4.8.5-39.el7.x86_64                                  2/7 
  Verifying  : libmpc-1.0.1-3.el7.x86_64                                    3/7 
  Verifying  : cpp-4.8.5-39.el7.x86_64                                      4/7 
  Verifying  : gcc-4.8.5-39.el7.x86_64                                      5/7 
  Verifying  : libgomp-4.8.2-16.el7.x86_64                                  6/7 
  Verifying  : libgcc-4.8.2-16.el7.x86_64                                   7/7 

Installed:
  gcc.x86_64 0:4.8.5-39.el7                                                     

Dependency Installed:
  cpp.x86_64 0:4.8.5-39.el7             libmpc.x86_64 0:1.0.1-3.el7            

Dependency Updated:
  libgcc.x86_64 0:4.8.5-39.el7           libgomp.x86_64 0:4.8.5-39.el7          

Complete!
[root@localhost /]# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../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-39) (GCC) 
[root@localhost /]# 
 

安装 gcc-c++ ;过程如下;

[root@localhost lixbo1]# yum -y install gcc-c++
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.163.com
 * extras: mirrors.cqu.edu.cn
 * updates: mirrors.cqu.edu.cn
Resolving Dependencies
--> Running transaction check
---> Package gcc-c++.x86_64 0:4.8.5-39.el7 will be installed
--> Processing Dependency: libstdc++-devel = 4.8.5-39.el7 for package: gcc-c++-4.8.5-39.el7.x86_64
--> Processing Dependency: libstdc++ = 4.8.5-39.el7 for package: gcc-c++-4.8.5-39.el7.x86_64
--> Running transaction check
---> Package libstdc++.x86_64 0:4.8.2-16.el7 will be updated
---> Package libstdc++.x86_64 0:4.8.5-39.el7 will be an update
---> Package libstdc++-devel.x86_64 0:4.8.5-39.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package                 Arch           Version              Repository    Size
================================================================================
Installing:
 gcc-c++                 x86_64         4.8.5-39.el7         base         7.2 M
Installing for dependencies:
 libstdc++-devel         x86_64         4.8.5-39.el7         base         1.5 M
Updating for dependencies:
 libstdc++               x86_64         4.8.5-39.el7         base         305 k

Transaction Summary
================================================================================
Install  1 Package  (+1 Dependent package)
Upgrade             ( 1 Dependent package)

Total download size: 9.0 M
Downloading packages:
No Presto metadata available for base
(1/3): libstdc++-4.8.5-39.el7.x86_64.rpm                   | 305 kB   00:02     
(2/3): libstdc++-devel-4.8.5-39.el7.x86_64.rpm             | 1.5 MB   00:03     
(3/3): gcc-c++-4.8.5-39.el7.x86_64.rpm                     | 7.2 MB   00:10     
--------------------------------------------------------------------------------
Total                                              905 kB/s | 9.0 MB  00:10     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Updating   : libstdc++-4.8.5-39.el7.x86_64                                1/4 
  Installing : libstdc++-devel-4.8.5-39.el7.x86_64                          2/4 
  Installing : gcc-c++-4.8.5-39.el7.x86_64                                  3/4 
  Cleanup    : libstdc++-4.8.2-16.el7.x86_64                                4/4 
  Verifying  : gcc-c++-4.8.5-39.el7.x86_64                                  1/4 
  Verifying  : libstdc++-devel-4.8.5-39.el7.x86_64                          2/4 
  Verifying  : libstdc++-4.8.5-39.el7.x86_64                                3/4 
  Verifying  : libstdc++-4.8.2-16.el7.x86_64                                4/4 

Installed:
  gcc-c++.x86_64 0:4.8.5-39.el7                                                 

Dependency Installed:
  libstdc++-devel.x86_64 0:4.8.5-39.el7                                         

Dependency Updated:
  libstdc++.x86_64 0:4.8.5-39.el7                                               

Complete!
[root@localhost lixbo1]# g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../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-39) (GCC) 
[root@localhost lixbo1]# 
 

安装gdb,过程如下;

[root@localhost lixbo1]# yum -y install gdb
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.163.com
 * extras: mirrors.cqu.edu.cn
 * updates: mirrors.cqu.edu.cn
Resolving Dependencies
--> Running transaction check
---> Package gdb.x86_64 0:7.6.1-51.el7 will be updated
---> Package gdb.x86_64 0:7.6.1-115.el7 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

==============================================================================================================================
 Package                   Arch                         Version                              Repository                  Size
==============================================================================================================================
Updating:
 gdb                       x86_64                       7.6.1-115.el7                        base                       2.4 M

Transaction Summary
==============================================================================================================================
Upgrade  1 Package

Total download size: 2.4 M
Downloading packages:
No Presto metadata available for base
gdb-7.6.1-115.el7.x86_64.rpm                                                                           | 2.4 MB  00:00:04     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Updating   : gdb-7.6.1-115.el7.x86_64                                                                                   1/2 
  Cleanup    : gdb-7.6.1-51.el7.x86_64                                                                                    2/2 
  Verifying  : gdb-7.6.1-115.el7.x86_64                                                                                   1/2 
  Verifying  : gdb-7.6.1-51.el7.x86_64                                                                                    2/2 

Updated:
  gdb.x86_64 0:7.6.1-115.el7                                                                                                  

Complete!
[root@localhost lixbo1]# 
 

安装git;过程如下;

[root@localhost lixbo1]# yum -y install git
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.163.com
 * extras: mirrors.cqu.edu.cn
 * updates: mirrors.cqu.edu.cn
Resolving Dependencies
--> Running transaction check
---> Package git.x86_64 0:1.8.3.1-21.el7_7 will be installed
--> Processing Dependency: perl-Git = 1.8.3.1-21.el7_7 for package: git-1.8.3.1-21.el7_7.x86_64
--> Processing Dependency: perl(Term::ReadKey) for package: git-1.8.3.1-21.el7_7.x86_64
--> Processing Dependency: perl(Git) for package: git-1.8.3.1-21.el7_7.x86_64
--> Processing Dependency: perl(Error) for package: git-1.8.3.1-21.el7_7.x86_64
--> Running transaction check
---> Package perl-Error.noarch 1:0.17020-2.el7 will be installed
---> Package perl-Git.noarch 0:1.8.3.1-21.el7_7 will be installed
---> Package perl-TermReadKey.x86_64 0:2.30-20.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==============================================================================================================================
 Package                           Arch                    Version                             Repository                Size
==============================================================================================================================
Installing:
 git                               x86_64                  1.8.3.1-21.el7_7                    updates                  4.4 M
Installing for dependencies:
 perl-Error                        noarch                  1:0.17020-2.el7                     base                      32 k
 perl-Git                          noarch                  1.8.3.1-21.el7_7                    updates                   55 k
 perl-TermReadKey                  x86_64                  2.30-20.el7                         base                      31 k

Transaction Summary
==============================================================================================================================
Install  1 Package (+3 Dependent packages)

Total download size: 4.5 M
Installed size: 22 M
Downloading packages:
(1/4): perl-Error-0.17020-2.el7.noarch.rpm                                                             |  32 kB  00:00:01     
(2/4): perl-Git-1.8.3.1-21.el7_7.noarch.rpm                                                            |  55 kB  00:00:01     
(3/4): perl-TermReadKey-2.30-20.el7.x86_64.rpm                                                         |  31 kB  00:00:01     
(4/4): git-1.8.3.1-21.el7_7.x86_64.rpm                                                                 | 4.4 MB  00:00:06     
------------------------------------------------------------------------------------------------------------------------------
Total                                                                                         671 kB/s | 4.5 MB  00:00:06     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : 1:perl-Error-0.17020-2.el7.noarch                                                                          1/4 
  Installing : perl-TermReadKey-2.30-20.el7.x86_64                                                                        2/4 
  Installing : perl-Git-1.8.3.1-21.el7_7.noarch                                                                           3/4 
  Installing : git-1.8.3.1-21.el7_7.x86_64                                                                                4/4 
  Verifying  : git-1.8.3.1-21.el7_7.x86_64                                                                                1/4 
  Verifying  : 1:perl-Error-0.17020-2.el7.noarch                                                                          2/4 
  Verifying  : perl-Git-1.8.3.1-21.el7_7.noarch                                                                           3/4 
  Verifying  : perl-TermReadKey-2.30-20.el7.x86_64                                                                        4/4 

Installed:
  git.x86_64 0:1.8.3.1-21.el7_7                                                                                               

Dependency Installed:
  perl-Error.noarch 1:0.17020-2.el7       perl-Git.noarch 0:1.8.3.1-21.el7_7       perl-TermReadKey.x86_64 0:2.30-20.el7      

Complete!
[root@localhost lixbo1]# 
 

安装vim插件;未成功;

[root@localhost lixbo1]# git clone https://gitee.com/chxuan/vimplus.git ~/.vimplus
Cloning into '/root/.vimplus'...
remote: Enumerating objects: 163, done.
remote: Counting objects: 100% (163/163), done.
remote: Compressing objects: 100% (161/161), done.
remote: Total 2191 (delta 95), reused 0 (delta 0), pack-reused 2028
Receiving objects: 100% (2191/2191), 12.68 MiB | 492.00 KiB/s, done.
Resolving deltas: 100% (1354/1354), done.
[root@localhost lixbo1]# cd ~/.vimplus
[root@localhost .vimplus]# dir
autoload  fonts     help.md    install_to_user.sh  README.md     uninstall.sh
colors      ftplugin  install.sh    LICENSE            screenshots  update.sh
[root@localhost .vimplus]# ./install.sh
Platform type: Linux
Linux distro: CentOS
Loaded plugins: fastestmirror, langpacks
Existing lock /var/run/yum.pid: another copy is running as pid 8969.
Another app is currently holding the yum lock; waiting for it to exit...
  The other application is: PackageKit
    Memory : 166 M RSS (569 MB VSZ)
    Started: Thu Mar 26 22:25:37 2020 - 08:47 ago
    State  : Sleeping, pid: 8969
Another app is currently holding the yum lock; waiting for it to exit...
  The other application is: PackageKit
    Memory : 166 M RSS (569 MB VSZ)
    Started: Thu Mar 26 22:25:37 2020 - 08:49 ago
    State  : Sleeping, pid: 8969
一直出 Another app is currently holding the yum lock ;下回再搞;

构建C++ hello world 程序;成功;

发布了475 篇原创文章 · 获赞 545 · 访问量 304万+

猜你喜欢

转载自blog.csdn.net/bcbobo21cn/article/details/105131176