报错如标题,我是ubuntu22.04安装redis3.2.4,其实版本没关系,看报错内容就好了。
解决:
参考了https://blog.csdn.net/fhw925464207/article/details/132079962这个链接的去解决gcc问题但是报错
可以在命令行输入如下的命令进行安装:
sudo apt-get install build-essential
也可以单个包进行安装,如:
sudo apt-get install libc6-dev
报错如下:
root@credit-201-ubuntu:/usr/local/redis-3.2.4# apt-get install libc6-dev
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
libc6-dev : Depends: libc6 (= 2.31-0ubuntu9.16) but 2.35-0ubuntu3 is to be installed
Depends: libc-dev-bin (= 2.31-0ubuntu9.16) but it is not going to be installed
Depends: libcrypt-dev but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
root@credit-201-ubuntu:/usr/local/redis-3.2.4#
这个错误信息表明你的系统上存在不同版本的 libc6
,而 libc6-dev
依赖于特定版本的 libc6
。
尝试解决
先替换源为以下阿里云的ubuntu22.04的版本
root@credit-201-ubuntu:~# more /etc/apt/sources.list
deb http://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse
再去安装安装这个包,这次安装就没报错了。
root@credit-201-ubuntu:/usr/local/redis-3.2.4# sudo apt-get install -f libc6-dev
这里安装没报错
root@credit-201-ubuntu:/usr/local/redis-3.2.4# make PREFIX=/usr/local/redis install
cd src && make install
make[1]: Entering directory '/usr/local/redis-3.2.4/src'
CC adlist.o
In file included from adlist.c:34:
zmalloc.h:50:10: fatal error: jemalloc/jemalloc.h: No such file or directory
50 | #include <jemalloc/jemalloc.h>
| ^~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make[1]: *** [Makefile:201: adlist.o] Error 1
make[1]: Leaving directory '/usr/local/redis-3.2.4/src'
make: *** [Makefile:9: install] Error 2
这个是上次编译缓存,清除即可
root@credit-201-ubuntu:/usr/local/redis-3.2.4# make distclean
然后再次编译
编译成功
总结,就是换源重新安装libc6-dev这个包。后面就成了。这是histroy