积微成著 不积跬步,无以至千里

首页   >   web开发   >   linux下安装redis,报错/bin/sh:cc:commandnotfound

linux下安装redis,报错/bin/sh:cc:commandnotfound

在linux环境中安装redis,使用make在redis目录编译源码时,报错提示:/bin/sh: cc: command not found,可能是由于新买的云服务器,并没有自带GCC。

在安装之前,稍微了解一下GCC是什么?

GCC可以用来编译C/C++、FORTRAN、JAVA、OBJC、ADA等语言的程序,可根据需要选择安装支持的语言。

好了,直接来看问题:

[root@jdu4e00u53f7 redis]# make
cd src && make all
make[1]: Entering directory `/usr/local/redis/src'
    CC Makefile.dep
make[1]: Leaving directory `/usr/local/redis/src'
make[1]: Entering directory `/usr/local/redis/src'
rm -rf redis-server redis-sentinel redis-cli redis-benchmark redis-check-rdb redis-check-aof *.o *.gcda *.gcno *.gcov redis.info lcov-html Makefile.dep dict-benchmark
(cd ../deps && make distclean)
make[2]: Entering directory `/usr/local/redis/deps'
(cd hiredis && make clean) > /dev/null || true
(cd linenoise && make clean) > /dev/null || true
(cd lua && make clean) > /dev/null || true
(cd jemalloc && [ -f Makefile ] && make distclean) > /dev/null || true
(rm -f .make-*)
make[2]: Leaving directory `/usr/local/redis/deps'
(rm -f .make-*)
echo STD=-std=c99 -pedantic -DREDIS_STATIC='' >> .make-settings
echo WARN=-Wall -W -Wno-missing-field-initializers >> .make-settings
echo OPT=-O2 >> .make-settings
echo MALLOC=jemalloc >> .make-settings
echo CFLAGS= >> .make-settings
echo LDFLAGS= >> .make-settings
echo REDIS_CFLAGS= >> .make-settings
echo REDIS_LDFLAGS= >> .make-settings
echo PREV_FINAL_CFLAGS=-std=c99 -pedantic -DREDIS_STATIC='' -Wall -W -Wno-missing-field-initializers -O2 -g -ggdb   -I../deps/hiredis -I../deps/linenoise -I../deps/lua/src -DUSE_JEMALLOC -I../deps/jemalloc/include >> .make-settings
echo PREV_FINAL_LDFLAGS=  -g -ggdb -rdynamic >> .make-settings
(cd ../deps && make hiredis linenoise lua jemalloc)
make[2]: Entering directory `/usr/local/redis/deps'
(cd hiredis && make clean) > /dev/null || true
(cd linenoise && make clean) > /dev/null || true
(cd lua && make clean) > /dev/null || true
(cd jemalloc && [ -f Makefile ] && make distclean) > /dev/null || true
(rm -f .make-*)
(echo "" > .make-cflags)
(echo "" > .make-ldflags)
MAKE hiredis
cd hiredis && make static
make[3]: Entering directory `/usr/local/redis/deps/hiredis'
gcc -std=c99 -pedantic -c -O3 -fPIC  -Wall -W -Wstrict-prototypes -Wwrite-strings -g -ggdb  net.c
make[3]: gcc: Command not found
make[3]: *** [net.o] Error 127
make[3]: Leaving directory `/usr/local/redis/deps/hiredis'
make[2]: *** [hiredis] Error 2
make[2]: Leaving directory `/usr/local/redis/deps'
make[1]: [persist-settings] Error 2 (ignored)
    CC adlist.o
/bin/sh: cc: command not found
make[1]: *** [adlist.o] Error 127
make[1]: Leaving directory `/usr/local/redis/src'
make: *** [all] Error 2

错误日志有点儿多,耐心点儿看,其中核心的就是/bin/sh: cc: command not found,既然缺失了,那就yum一个

[root@jdu4e00u53f7 redis]# yum install -y gcc
Loaded plugins: fastestmirror
Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
base                                                                                                                                                                                                                                                   | 3.6 kB  00:00:00     
extras                                                                                                                                                                                                                                                 | 3.4 kB  00:00:00     
updates                                                                                                                                                                                                                                                | 3.4 kB  00:00:00     
(1/4): base/7/x86_64/group_gz                                                                                                                                                                                                                          | 156 kB  00:00:00     
(2/4): extras/7/x86_64/primary_db                                                                                                                                                                                                                      | 110 kB  00:00:00     
(3/4): updates/7/x86_64/primary_db                                                                                                                                                                                                                     | 2.7 MB  00:00:00     
(4/4): base/7/x86_64/primary_db                                                                                                                                                                                                                        | 5.7 MB  00:00:00     
Determining fastest mirrors
Resolving Dependencies
--> Running transaction check
---> Package gcc.x86_64 0:4.8.5-16.el7 will be installed
--> Processing Dependency: libgomp = 4.8.5-16.el7 for package: gcc-4.8.5-16.el7.x86_64
--> Processing Dependency: cpp = 4.8.5-16.el7 for package: gcc-4.8.5-16.el7.x86_64
--> Processing Dependency: libgcc >= 4.8.5-16.el7 for package: gcc-4.8.5-16.el7.x86_64
--> Processing Dependency: glibc-devel >= 2.2.90-12 for package: gcc-4.8.5-16.el7.x86_64
--> Processing Dependency: libmpfr.so.4()(64bit) for package: gcc-4.8.5-16.el7.x86_64
--> Processing Dependency: libmpc.so.3()(64bit) for package: gcc-4.8.5-16.el7.x86_64
--> Running transaction check
---> Package cpp.x86_64 0:4.8.5-16.el7 will be installed
---> Package glibc-devel.x86_64 0:2.17-196.el7 will be installed
--> Processing Dependency: glibc-headers = 2.17-196.el7 for package: glibc-devel-2.17-196.el7.x86_64
--> Processing Dependency: glibc = 2.17-196.el7 for package: glibc-devel-2.17-196.el7.x86_64
--> Processing Dependency: glibc-headers for package: glibc-devel-2.17-196.el7.x86_64
---> Package libgcc.x86_64 0:4.8.5-11.el7 will be updated
---> Package libgcc.x86_64 0:4.8.5-16.el7 will be an update
---> Package libgomp.x86_64 0:4.8.5-11.el7 will be updated
---> Package libgomp.x86_64 0:4.8.5-16.el7 will be an update
---> Package libmpc.x86_64 0:1.0.1-3.el7 will be installed
---> Package mpfr.x86_64 0:3.1.1-4.el7 will be installed
--> Running transaction check
---> Package glibc.x86_64 0:2.17-157.el7_3.4 will be updated
--> Processing Dependency: glibc = 2.17-157.el7_3.4 for package: nscd-2.17-157.el7_3.4.x86_64
--> Processing Dependency: glibc = 2.17-157.el7_3.4 for package: glibc-common-2.17-157.el7_3.4.x86_64
---> Package glibc.x86_64 0:2.17-196.el7 will be an update
---> Package glibc-headers.x86_64 0:2.17-196.el7 will be installed
--> Processing Dependency: kernel-headers >= 2.2.1 for package: glibc-headers-2.17-196.el7.x86_64
--> Processing Dependency: kernel-headers for package: glibc-headers-2.17-196.el7.x86_64
--> Running transaction check
---> Package glibc-common.x86_64 0:2.17-157.el7_3.4 will be updated
---> Package glibc-common.x86_64 0:2.17-196.el7 will be an update
---> Package kernel-headers.x86_64 0:3.10.0-693.2.2.el7 will be installed
---> Package nscd.x86_64 0:2.17-157.el7_3.4 will be updated
---> Package nscd.x86_64 0:2.17-196.el7 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

==============================================================================================================================================================================================================================================================================
 Package                                                             Arch                                                        Version                                                                   Repository                                                    Size
==============================================================================================================================================================================================================================================================================
Installing:
 gcc                                                                 x86_64                                                      4.8.5-16.el7                                                              base                                                          16 M
Installing for dependencies:
 cpp                                                                 x86_64                                                      4.8.5-16.el7                                                              base                                                         5.9 M
 glibc-devel                                                         x86_64                                                      2.17-196.el7                                                              base                                                         1.1 M
 glibc-headers                                                       x86_64                                                      2.17-196.el7                                                              base                                                         675 k
 kernel-headers                                                      x86_64                                                      3.10.0-693.2.2.el7                                                        updates                                                      6.0 M
 libmpc                                                              x86_64                                                      1.0.1-3.el7                                                               base                                                          51 k
 mpfr                                                                x86_64                                                      3.1.1-4.el7                                                               base                                                         203 k
Updating for dependencies:
 glibc                                                               x86_64                                                      2.17-196.el7                                                              base                                                         3.6 M
 glibc-common                                                        x86_64                                                      2.17-196.el7                                                              base                                                          11 M
 libgcc                                                              x86_64                                                      4.8.5-16.el7                                                              base                                                          98 k
 libgomp                                                             x86_64                                                      4.8.5-16.el7                                                              base                                                         154 k
 nscd                                                                x86_64                                                      2.17-196.el7                                                              base                                                         273 k

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

Total download size: 46 M
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
(1/12): cpp-4.8.5-16.el7.x86_64.rpm                                                                                                                                                                                                                    | 5.9 MB  00:00:00     
(2/12): glibc-2.17-196.el7.x86_64.rpm                                                                                                                                                                                                                  | 3.6 MB  00:00:00     
(3/12): gcc-4.8.5-16.el7.x86_64.rpm                                                                                                                                                                                                                    |  16 MB  00:00:01     
(4/12): glibc-devel-2.17-196.el7.x86_64.rpm                                                                                                                                                                                                            | 1.1 MB  00:00:00     
(5/12): glibc-headers-2.17-196.el7.x86_64.rpm                                                                                                                                                                                                          | 675 kB  00:00:00     
(6/12): libgcc-4.8.5-16.el7.x86_64.rpm                                                                                                                                                                                                                 |  98 kB  00:00:00     
(7/12): libgomp-4.8.5-16.el7.x86_64.rpm                                                                                                                                                                                                                | 154 kB  00:00:00     
(8/12): libmpc-1.0.1-3.el7.x86_64.rpm                                                                                                                                                                                                                  |  51 kB  00:00:00     
(9/12): mpfr-3.1.1-4.el7.x86_64.rpm                                                                                                                                                                                                                    | 203 kB  00:00:00     
(10/12): nscd-2.17-196.el7.x86_64.rpm                                                                                                                                                                                                                  | 273 kB  00:00:00     
(11/12): glibc-common-2.17-196.el7.x86_64.rpm                                                                                                                                                                                                          |  11 MB  00:00:01     
(12/12): kernel-headers-3.10.0-693.2.2.el7.x86_64.rpm                                                                                                                                                                                                  | 6.0 MB  00:00:00     
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                                                                                                          17 MB/s |  46 MB  00:00:02     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Updating   : libgcc-4.8.5-16.el7.x86_64                                                                                                                                                                                                                                1/17 
  Updating   : glibc-common-2.17-196.el7.x86_64                                                                                                                                                                                                                          2/17 
  Updating   : glibc-2.17-196.el7.x86_64                                                                                                                                                                                                                                 3/17 
warning: /etc/nsswitch.conf created as /etc/nsswitch.conf.rpmnew
  Installing : mpfr-3.1.1-4.el7.x86_64                                                                                                                                                                                                                                   4/17 
  Installing : libmpc-1.0.1-3.el7.x86_64                                                                                                                                                                                                                                 5/17 
  Installing : cpp-4.8.5-16.el7.x86_64                                                                                                                                                                                                                                   6/17 
  Updating   : libgomp-4.8.5-16.el7.x86_64                                                                                                                                                                                                                               7/17 
  Installing : kernel-headers-3.10.0-693.2.2.el7.x86_64                                                                                                                                                                                                                  8/17 
  Installing : glibc-headers-2.17-196.el7.x86_64                                                                                                                                                                                                                         9/17 
  Installing : glibc-devel-2.17-196.el7.x86_64                                                                                                                                                                                                                          10/17 
  Installing : gcc-4.8.5-16.el7.x86_64                                                                                                                                                                                                                                  11/17 
  Updating   : nscd-2.17-196.el7.x86_64                                                                                                                                                                                                                                 12/17 
  Cleanup    : nscd-2.17-157.el7_3.4.x86_64                                                                                                                                                                                                                             13/17 
  Cleanup    : libgomp-4.8.5-11.el7.x86_64                                                                                                                                                                                                                              14/17 
  Cleanup    : glibc-2.17-157.el7_3.4.x86_64                                                                                                                                                                                                                            15/17 
  Cleanup    : glibc-common-2.17-157.el7_3.4.x86_64                                                                                                                                                                                                                     16/17 
  Cleanup    : libgcc-4.8.5-11.el7.x86_64                                                                                                                                                                                                                               17/17 
  Verifying  : libgcc-4.8.5-16.el7.x86_64                                                                                                                                                                                                                                1/17 
  Verifying  : glibc-common-2.17-196.el7.x86_64                                                                                                                                                                                                                          2/17 
  Verifying  : kernel-headers-3.10.0-693.2.2.el7.x86_64                                                                                                                                                                                                                  3/17 
  Verifying  : mpfr-3.1.1-4.el7.x86_64                                                                                                                                                                                                                                   4/17 
  Verifying  : libgomp-4.8.5-16.el7.x86_64                                                                                                                                                                                                                               5/17 
  Verifying  : cpp-4.8.5-16.el7.x86_64                                                                                                                                                                                                                                   6/17 
  Verifying  : gcc-4.8.5-16.el7.x86_64                                                                                                                                                                                                                                   7/17 
  Verifying  : glibc-headers-2.17-196.el7.x86_64                                                                                                                                                                                                                         8/17 
  Verifying  : glibc-devel-2.17-196.el7.x86_64                                                                                                                                                                                                                           9/17 
  Verifying  : glibc-2.17-196.el7.x86_64                                                                                                                                                                                                                                10/17 
  Verifying  : nscd-2.17-196.el7.x86_64                                                                                                                                                                                                                                 11/17 
  Verifying  : libmpc-1.0.1-3.el7.x86_64                                                                                                                                                                                                                                12/17 
  Verifying  : glibc-common-2.17-157.el7_3.4.x86_64                                                                                                                                                                                                                     13/17 
  Verifying  : nscd-2.17-157.el7_3.4.x86_64                                                                                                                                                                                                                             14/17 
  Verifying  : libgomp-4.8.5-11.el7.x86_64                                                                                                                                                                                                                              15/17 
  Verifying  : glibc-2.17-157.el7_3.4.x86_64                                                                                                                                                                                                                            16/17 
  Verifying  : libgcc-4.8.5-11.el7.x86_64                                                                                                                                                                                                                               17/17 

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

Dependency Installed:
  cpp.x86_64 0:4.8.5-16.el7             glibc-devel.x86_64 0:2.17-196.el7             glibc-headers.x86_64 0:2.17-196.el7             kernel-headers.x86_64 0:3.10.0-693.2.2.el7             libmpc.x86_64 0:1.0.1-3.el7             mpfr.x86_64 0:3.1.1-4.el7            

Dependency Updated:
  glibc.x86_64 0:2.17-196.el7                         glibc-common.x86_64 0:2.17-196.el7                         libgcc.x86_64 0:4.8.5-16.el7                         libgomp.x86_64 0:4.8.5-16.el7                         nscd.x86_64 0:2.17-196.el7                        

Complete!

可以看到,并非只安装了gcc,还安装了一系列gcc的依赖,没什么问题,继续执行make编译源码。

日志文件太多,在之前的文章 linux环境下安装redis3.2 中已经展示过了,这里就只放一张截图

linux下安装redis,报错 /bin/sh: cc: command not found

信息是真的多,这是拖到最下面截的一张屏,如果服务器环境都正常,基本上一遍就可以成功!

QQ群:积微成著官方群(686430774),验证消息:积微成著

站长Q:1347384268(加好友请注明来意)

分享到:

欢迎分享本文,转载请注明出处!

作者:不忘初心

发布时间:2017-10-13

永久地址:http://www.jiweichengzhu.com/article/ef46724571634ad98f2c9795480cc3fc