Windows下编译安装Redis


继上次Windows下安装MySQL后,今天安装Redis发现也复杂许多,github上有几个仓库似乎提供了windows一键安装版,但是到 5.0版本就不更新了……所以Macbook真的好使 o(﹏)o

由于Redis本来就是不支持Windows的,为了安装Redis我们首先需要安装另一个工具:cygwin。这个工具能帮助我们在Windows上运行类UNIX模拟环境。

本文安装环境:Windows11 + redis-6.2.10+ cygwin-x86_64

1.下载cygwin

下载地址:https://cygwin.com/
在这里插入图片描述

2.安装cygwin

双击下载的.exe文件一路next下去就行了。

如果在选择镜像时没有加载出镜像列表,可以输入http://mirrors.aliyun.com/cygwin/,然后点击旁边的Add。

在这里插入图片描述

到 Select Packages 时注意一下,这里我们要额外添加 make,gcc-core,gcc-g++,这三个默认是不安装的,就是其他的都是skip,要安装的随便选择个版本就好

在这里插入图片描述

安装后,桌面上会出现一个快捷方式,双击图标就可以用。如果双击完提示”Windows正在查找mintty”,首先查看安装目录(比如我的就是C:\cygwin64)下的bin包里有没有mintty.exe文件,如果没有就重新安装。如果有查看下快捷键的目标里是不是”C:\cygwin64\bin\mintty.exe -i /Cygwin-Terminal.ico -“,尤其检查有没有.exe结尾。

在这里插入图片描述

如果后面安装时发现有漏掉的命令没安装也没关系,重新双击.exe文件重新安装一遍就行,上一遍已经安装上的不会丢失,只需要找到你这次想补上的就可以。

后面步骤的所有命令行都在cygwin下运行。

3.下载Redis

下载地址:https://redis.io/download

4.编译Redis

首先将下载的redis进行解压,

然后将里面deps文件夹下的hiredis删掉.从git上重新拉取一个新的(压缩包里的有问题,编译时报错)这个看情况操作,此版本我没有操作未报错,然后操作是在deps文件夹下操作

在cygwin里cd,cd F:/redis/redis-6.2.10/deps

git clone https://github.com/redis/hiredis.git

然后把deps目录下几个文件夹编译一下,在deps下执行

make hiredis jemalloc linenoise lua

然后回到 redis 根目录执行

make && make install

在这里插入图片描述

在这里插入图片描述

5.运行redis

到 src 目录下执行

redis-server

完美运行!

在这里插入图片描述

在这里插入图片描述

6.报错:

debug.c: In function ‘dumpX86Calls’:
debug.c:1767:5: error: unknown type name ‘Dl_info’
     Dl_info info;
     ^~~~~~~
debug.c:1777:13: warning: implicit declaration of function ‘dladdr’; did you mean ‘s_addr’? [-Wimplicit-function-declaration]
         if (dladdr((void*)target, &info) != 0 && info.dli_sname != NULL) {
             ^~~~~~
             s_addr
debug.c:1777:54: error: request for member ‘dli_sname’ in something not a structure or union
         if (dladdr((void*)target, &info) != 0 && info.dli_sname != NULL) {
                                                      ^
debug.c:1779:63: error: request for member ‘dli_sname’ in something not a structure or union
                 printf("Function at 0x%lx is %s\n",target,info.dli_sname);
                                                               ^
debug.c: In function ‘dumpCodeAroundEIP’:
debug.c:1788:5: error: unknown type name ‘Dl_info’
     Dl_info info;
     ^~~~~~~
In file included from debug.c:31:0:
debug.c:1797:17: error: request for member ‘dli_sname’ in something not a structure or union
             info.dli_sname, info.dli_saddr, info.dli_fname, info.dli_fbase,
                 ^
server.h:2761:27: note: in definition of macro ‘serverLog’
         _serverLog(level, __VA_ARGS__);\
                           ^~~~~~~~~~~
debug.c:1797:33: error: request for member ‘dli_saddr’ in something not a structure or union
             info.dli_sname, info.dli_saddr, info.dli_fname, info.dli_fbase,
                                 ^
server.h:2761:27: note: in definition of macro ‘serverLog’
         _serverLog(level, __VA_ARGS__);\
                           ^~~~~~~~~~~
debug.c:1797:49: error: request for member ‘dli_fname’ in something not a structure or union
             info.dli_sname, info.dli_saddr, info.dli_fname, info.dli_fbase,
                                                 ^
server.h:2761:27: note: in definition of macro ‘serverLog’
         _serverLog(level, __VA_ARGS__);\
                           ^~~~~~~~~~~
debug.c:1797:65: error: request for member ‘dli_fbase’ in something not a structure or union
             info.dli_sname, info.dli_saddr, info.dli_fname, info.dli_fbase,
                                                                 ^
server.h:2761:27: note: in definition of macro ‘serverLog’
         _serverLog(level, __VA_ARGS__);\
                           ^~~~~~~~~~~
debug.c:1798:17: error: request for member ‘dli_saddr’ in something not a structure or union
             info.dli_saddr);
                 ^
server.h:2761:27: note: in definition of macro ‘serverLog’
         _serverLog(level, __VA_ARGS__);\
                           ^~~~~~~~~~~
debug.c:1799:44: error: request for member ‘dli_saddr’ in something not a structure or union
         size_t len = (long)eip - (long)info.dli_saddr;
                                            ^
debug.c:1805:38: error: request for member ‘dli_saddr’ in something not a structure or union
             void *base = (void *)info.dli_saddr;
                                      ^
make[1]: *** [Makefile:376: debug.o] Error 1
make[1]: Leaving directory '/cygdrive/f/redis/redis-6.2.10/src'
make: *** [Makefile:6: all] Error 2

解决:打开cygwin具体位置(“F:\cygwin\usr\include\dlfcn.h”)

注释两个东西

在这里插入图片描述

在这里插入图片描述

49 //#if __GNU_VISIBLE
61 //#endif

这个在github上有描述:地址

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

cai-4

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值