解決centos "g++: Command not found"報錯問題

在centos編譯C++代碼時,如果有如下提示:

Invoking: GCC C++ Compiler
g++ -std=c++1y -fpermissive -Iusr/local/include/zlib/include/ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"Epoll.d" -MT"Epoll.o" -o "Epoll.o" "../Epoll.cpp"
/bin/sh: g++: command not found
make: *** [Epoll.o] Error 127

則需要檢查下g++的版本信息

通過"yum search "gcc-c++""命令檢查缺少組件的版本,畢竟不同系統需要安裝的版本是不同的。

Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
============================================================================================================================ N/S matched: gcc-c++ ============================================================================================================================
avr-gcc-c++.x86_64 : Cross Compiling GNU GCC targeted at avr
gcc-c++.x86_64 : C++ support for GCC
gcc-c++-aarch64-linux-gnu.x86_64 : Cross-build binary utilities for aarch64-linux-gnu
gcc-c++-alpha-linux-gnu.x86_64 : Cross-build binary utilities for alpha-linux-gnu
gcc-c++-arm-linux-gnu.x86_64 : Cross-build binary utilities for arm-linux-gnu
gcc-c++-avr32-linux-gnu.x86_64 : Cross-build binary utilities for avr32-linux-gnu
gcc-c++-bfin-linux-gnu.x86_64 : Cross-build binary utilities for bfin-linux-gnu
gcc-c++-c6x-linux-gnu.x86_64 : Cross-build binary utilities for c6x-linux-gnu
gcc-c++-cris-linux-gnu.x86_64 : Cross-build binary utilities for cris-linux-gnu
gcc-c++-frv-linux-gnu.x86_64 : Cross-build binary utilities for frv-linux-gnu
gcc-c++-h8300-linux-gnu.x86_64 : Cross-build binary utilities for h8300-linux-gnu
gcc-c++-hppa-linux-gnu.x86_64 : Cross-build binary utilities for hppa-linux-gnu
gcc-c++-hppa64-linux-gnu.x86_64 : Cross-build binary utilities for hppa64-linux-gnu
gcc-c++-ia64-linux-gnu.x86_64 : Cross-build binary utilities for ia64-linux-gnu
gcc-c++-m32r-linux-gnu.x86_64 : Cross-build binary utilities for m32r-linux-gnu
gcc-c++-m68k-linux-gnu.x86_64 : Cross-build binary utilities for m68k-linux-gnu
gcc-c++-microblaze-linux-gnu.x86_64 : Cross-build binary utilities for microblaze-linux-gnu
gcc-c++-mips64-linux-gnu.x86_64 : Cross-build binary utilities for mips64-linux-gnu
gcc-c++-mn10300-linux-gnu.x86_64 : Cross-build binary utilities for mn10300-linux-gnu
gcc-c++-powerpc64-linux-gnu.x86_64 : Cross-build binary utilities for powerpc64-linux-gnu
gcc-c++-ppc64-linux-gnu.x86_64 : Cross-build binary utilities for ppc64-linux-gnu
gcc-c++-s390x-linux-gnu.x86_64 : Cross-build binary utilities for s390x-linux-gnu
gcc-c++-sh-linux-gnu.x86_64 : Cross-build binary utilities for sh-linux-gnu
gcc-c++-sh64-linux-gnu.x86_64 : Cross-build binary utilities for sh64-linux-gnu
gcc-c++-sparc64-linux-gnu.x86_64 : Cross-build binary utilities for sparc64-linux-gnu
gcc-c++-tile-linux-gnu.x86_64 : Cross-build binary utilities for tile-linux-gnu
gcc-c++-x86_64-linux-gnu.x86_64 : Cross-build binary utilities for x86_64-linux-gnu
gcc-c++-xtensa-linux-gnu.x86_64 : Cross-build binary utilities for xtensa-linux-gnu

按照提示安裝對應版本

[root@VM_32_16_centos code]# yum install "gcc-c++.x86_64" -y
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
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
--> Processing Dependency: gcc = 4.8.5-39.el7 for package: gcc-c++-4.8.5-39.el7.x86_64
--> Processing Dependency: libmpfr.so.4()(64bit) for package: gcc-c++-4.8.5-39.el7.x86_64
--> Processing Dependency: libmpc.so.3()(64bit) for package: gcc-c++-4.8.5-39.el7.x86_64
--> 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: glibc-devel >= 2.2.90-12 for package: gcc-4.8.5-39.el7.x86_64
---> Package libmpc.x86_64 0:1.0.1-3.el7 will be installed
---> Package libstdc++.x86_64 0:4.8.5-28.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
---> Package mpfr.x86_64 0:3.1.1-4.el7 will be installed
--> Running transaction check
---> Package cpp.x86_64 0:4.8.5-39.el7 will be installed
---> Package glibc-devel.x86_64 0:2.17-292.el7 will be installed
--> Processing Dependency: glibc-headers = 2.17-292.el7 for package: glibc-devel-2.17-292.el7.x86_64
--> Processing Dependency: glibc = 2.17-292.el7 for package: glibc-devel-2.17-292.el7.x86_64
--> Processing Dependency: glibc-headers for package: glibc-devel-2.17-292.el7.x86_64
---> Package libgcc.x86_64 0:4.8.5-28.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.5-28.el7 will be updated
---> Package libgomp.x86_64 0:4.8.5-39.el7 will be an update
--> Running transaction check
---> Package glibc.x86_64 0:2.17-222.el7 will be updated
--> Processing Dependency: glibc = 2.17-222.el7 for package: glibc-common-2.17-222.el7.x86_64
---> Package glibc.x86_64 0:2.17-292.el7 will be an update
---> Package glibc-headers.x86_64 0:2.17-292.el7 will be installed
--> Processing Dependency: kernel-headers >= 2.2.1 for package: glibc-headers-2.17-292.el7.x86_64
--> Processing Dependency: kernel-headers for package: glibc-headers-2.17-292.el7.x86_64
--> Running transaction check
---> Package glibc-common.x86_64 0:2.17-222.el7 will be updated
---> Package glibc-common.x86_64 0:2.17-292.el7 will be an update
---> Package kernel-headers.x86_64 0:3.10.0-1062.12.1.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==============================================================================================================================================================================================================================================================================
 Package                                                             Arch                                                       Version                                                                     Repository                                                   Size
==============================================================================================================================================================================================================================================================================
Installing:
 gcc-c++                                                             x86_64                                                     4.8.5-39.el7                                                                os                                                          7.2 M
Installing for dependencies:
 cpp                                                                 x86_64                                                     4.8.5-39.el7                                                                os                                                          5.9 M
 gcc                                                                 x86_64                                                     4.8.5-39.el7                                                                os                                                           16 M
 glibc-devel                                                         x86_64                                                     2.17-292.el7                                                                os                                                          1.1 M
 glibc-headers                                                       x86_64                                                     2.17-292.el7                                                                os                                                          687 k
 kernel-headers                                                      x86_64                                                     3.10.0-1062.12.1.el7                                                        updates                                                     8.7 M
 libmpc                                                              x86_64                                                     1.0.1-3.el7                                                                 os                                                           51 k
 libstdc++-devel                                                     x86_64                                                     4.8.5-39.el7                                                                os                                                          1.5 M
 mpfr                                                                x86_64                                                     3.1.1-4.el7                                                                 os                                                          203 k
Updating for dependencies:
 glibc                                                               x86_64                                                     2.17-292.el7                                                                os                                                          3.6 M
 glibc-common                                                        x86_64                                                     2.17-292.el7                                                                os                                                           11 M
 libgcc                                                              x86_64                                                     4.8.5-39.el7                                                                os                                                          102 k
 libgomp                                                             x86_64                                                     4.8.5-39.el7                                                                os                                                          158 k
 libstdc++                                                           x86_64                                                     4.8.5-39.el7                                                                os                                                          305 k

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

Total download size: 57 M
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
(1/14): cpp-4.8.5-39.el7.x86_64.rpm                                                                                                                                                                                                                    | 5.9 MB  00:00:00     
(2/14): gcc-c++-4.8.5-39.el7.x86_64.rpm                                                                                                                                                                                                                | 7.2 MB  00:00:00     
(3/14): glibc-2.17-292.el7.x86_64.rpm                                                                                                                                                                                                                  | 3.6 MB  00:00:00     
(4/14): glibc-common-2.17-292.el7.x86_64.rpm                                                                                                                                                                                                           |  11 MB  00:00:00     
(5/14): glibc-devel-2.17-292.el7.x86_64.rpm                                                                                                                                                                                                            | 1.1 MB  00:00:00     
(6/14): glibc-headers-2.17-292.el7.x86_64.rpm                                                                                                                                                                                                          | 687 kB  00:00:00     
(7/14): libgcc-4.8.5-39.el7.x86_64.rpm                                                                                                                                                                                                                 | 102 kB  00:00:00     
(8/14): libgomp-4.8.5-39.el7.x86_64.rpm                                                                                                                                                                                                                | 158 kB  00:00:00     
(9/14): libmpc-1.0.1-3.el7.x86_64.rpm                                                                                                                                                                                                                  |  51 kB  00:00:00     
(10/14): libstdc++-4.8.5-39.el7.x86_64.rpm                                                                                                                                                                                                             | 305 kB  00:00:00     
(11/14): libstdc++-devel-4.8.5-39.el7.x86_64.rpm                                                                                                                                                                                                       | 1.5 MB  00:00:00     
(12/14): mpfr-3.1.1-4.el7.x86_64.rpm                                                                                                                                                                                                                   | 203 kB  00:00:00     
(13/14): kernel-headers-3.10.0-1062.12.1.el7.x86_64.rpm                                                                                                                                                                                                | 8.7 MB  00:00:00     
(14/14): gcc-4.8.5-39.el7.x86_64.rpm                                                                                                                                                                                                                   |  16 MB  00:00:01     
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                                                                                                          44 MB/s |  57 MB  00:00:01     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Updating   : libgcc-4.8.5-39.el7.x86_64                                                                                                                                                                                                                                1/19 
/sbin/ldconfig: /lib64/libZThread-2.3.so.2 is not a symbolic link

  Updating   : glibc-2.17-292.el7.x86_64                                                                                                                                                                                                                                 2/19 
warning: /etc/nsswitch.conf created as /etc/nsswitch.conf.rpmnew
/sbin/ldconfig: /lib64/libZThread-2.3.so.2 is not a symbolic link

  Updating   : glibc-common-2.17-292.el7.x86_64                                                                                                                                                                                                                          3/19 
  Installing : mpfr-3.1.1-4.el7.x86_64                                                                                                                                                                                                                                   4/19 
/sbin/ldconfig: /lib64/libZThread-2.3.so.2 is not a symbolic link

  Installing : libmpc-1.0.1-3.el7.x86_64                                                                                                                                                                                                                                 5/19 
/sbin/ldconfig: /lib64/libZThread-2.3.so.2 is not a symbolic link

  Updating   : libstdc++-4.8.5-39.el7.x86_64                                                                                                                                                                                                                             6/19 
/sbin/ldconfig: /lib64/libZThread-2.3.so.2 is not a symbolic link

  Installing : libstdc++-devel-4.8.5-39.el7.x86_64                                                                                                                                                                                                                       7/19 
  Installing : cpp-4.8.5-39.el7.x86_64                                                                                                                                                                                                                                   8/19 
  Updating   : libgomp-4.8.5-39.el7.x86_64                                                                                                                                                                                                                               9/19 
/sbin/ldconfig: /lib64/libZThread-2.3.so.2 is not a symbolic link

  Installing : kernel-headers-3.10.0-1062.12.1.el7.x86_64                                                                                                                                                                                                               10/19 
  Installing : glibc-headers-2.17-292.el7.x86_64                                                                                                                                                                                                                        11/19 
  Installing : glibc-devel-2.17-292.el7.x86_64                                                                                                                                                                                                                          12/19 
  Installing : gcc-4.8.5-39.el7.x86_64                                                                                                                                                                                                                                  13/19 
  Installing : gcc-c++-4.8.5-39.el7.x86_64                                                                                                                                                                                                                              14/19 
  Cleanup    : libstdc++-4.8.5-28.el7.x86_64                                                                                                                                                                                                                            15/19 
/sbin/ldconfig: /lib64/libZThread-2.3.so.2 is not a symbolic link

  Cleanup    : libgomp-4.8.5-28.el7.x86_64                                                                                                                                                                                                                              16/19 
/sbin/ldconfig: /lib64/libZThread-2.3.so.2 is not a symbolic link

  Cleanup    : glibc-2.17-222.el7.x86_64                                                                                                                                                                                                                                17/19 
/sbin/ldconfig: /lib64/libZThread-2.3.so.2 is not a symbolic link

  Cleanup    : glibc-common-2.17-222.el7.x86_64                                                                                                                                                                                                                         18/19 
  Cleanup    : libgcc-4.8.5-28.el7.x86_64                                                                                                                                                                                                                               19/19 
/sbin/ldconfig: /lib64/libZThread-2.3.so.2 is not a symbolic link

  Verifying  : glibc-devel-2.17-292.el7.x86_64                                                                                                                                                                                                                           1/19 
  Verifying  : glibc-common-2.17-292.el7.x86_64                                                                                                                                                                                                                          2/19 
  Verifying  : glibc-2.17-292.el7.x86_64                                                                                                                                                                                                                                 3/19 
  Verifying  : gcc-c++-4.8.5-39.el7.x86_64                                                                                                                                                                                                                               4/19 
  Verifying  : mpfr-3.1.1-4.el7.x86_64                                                                                                                                                                                                                                   5/19 
  Verifying  : kernel-headers-3.10.0-1062.12.1.el7.x86_64                                                                                                                                                                                                                6/19 
  Verifying  : libgcc-4.8.5-39.el7.x86_64                                                                                                                                                                                                                                7/19 
  Verifying  : libgomp-4.8.5-39.el7.x86_64                                                                                                                                                                                                                               8/19 
  Verifying  : libmpc-1.0.1-3.el7.x86_64                                                                                                                                                                                                                                 9/19 
  Verifying  : cpp-4.8.5-39.el7.x86_64                                                                                                                                                                                                                                  10/19 
  Verifying  : gcc-4.8.5-39.el7.x86_64                                                                                                                                                                                                                                  11/19 
  Verifying  : libstdc++-devel-4.8.5-39.el7.x86_64                                                                                                                                                                                                                      12/19 
  Verifying  : glibc-headers-2.17-292.el7.x86_64                                                                                                                                                                                                                        13/19 
  Verifying  : libstdc++-4.8.5-39.el7.x86_64                                                                                                                                                                                                                            14/19 
  Verifying  : glibc-common-2.17-222.el7.x86_64                                                                                                                                                                                                                         15/19 
  Verifying  : libgomp-4.8.5-28.el7.x86_64                                                                                                                                                                                                                              16/19 
  Verifying  : libstdc++-4.8.5-28.el7.x86_64                                                                                                                                                                                                                            17/19 
  Verifying  : glibc-2.17-222.el7.x86_64                                                                                                                                                                                                                                18/19 
  Verifying  : libgcc-4.8.5-28.el7.x86_64                                                                                                                                                                                                                               19/19 

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

Dependency Installed:
  cpp.x86_64 0:4.8.5-39.el7  gcc.x86_64 0:4.8.5-39.el7  glibc-devel.x86_64 0:2.17-292.el7  glibc-headers.x86_64 0:2.17-292.el7  kernel-headers.x86_64 0:3.10.0-1062.12.1.el7  libmpc.x86_64 0:1.0.1-3.el7  libstdc++-devel.x86_64 0:4.8.5-39.el7  mpfr.x86_64 0:3.1.1-4.el7 

Dependency Updated:
  glibc.x86_64 0:2.17-292.el7                        glibc-common.x86_64 0:2.17-292.el7                        libgcc.x86_64 0:4.8.5-39.el7                        libgomp.x86_64 0:4.8.5-39.el7                        libstdc++.x86_64 0:4.8.5-39.el7                       

Complete!

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章