Winse Blog

走走停停, 熙熙攘攘, 忙忙碌碌, 不知何畏.

Build redis-2.8 on Cygwin

由于cygwin环境,模拟的linux,有部分的变量没有定义,需要进行修改。修改如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
$ git log -1
commit 0c211a1953afeda3d0d45126653e2d4c38bd88cb
Author: antirez <antirez@gmail.com>
Date:   Fri Dec 5 10:51:09 2014 +010

$ git branch
* 2.8

$ git diff
diff --git a/deps/hiredis/net.c b/deps/hiredis/net.c
index bdb84ce..6e95f22 100644
--- a/deps/hiredis/net.c
+++ b/deps/hiredis/net.c
@@ -51,6 +51,13 @@
 #include "net.h"
 #include "sds.h"

+/* Cygwin Fix */
+#ifdef __CYGWIN__
+#define TCP_KEEPCNT 8
+#define TCP_KEEPINTVL 150
+#define TCP_KEEPIDLE 14400
+#endif
+
 /* Defined in hiredis.c */
 void __redisSetError(redisContext *c, int type, const char *str);

diff --git a/src/Makefile b/src/Makefile
index 8b3e959..a72b2f2 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -63,6 +63,9 @@ else
 ifeq ($(uname_S),Darwin)
        # Darwin (nothing to do)
 else
+ifeq ($(uname_S),CYGWIN_NT-6.3-WOW64)
+       # cygwin (nothing to do)
+else
 ifeq ($(uname_S),AIX)
         # AIX
         FINAL_LDFLAGS+= -Wl,-bexpall
@@ -75,6 +78,7 @@ else
 endif
 endif
 endif
+endif
 # Include paths to dependencies
 FINAL_CFLAGS+= -I../deps/hiredis -I../deps/linenoise -I../deps/lua/src

然后编译:

1
2
3
4
5
cd deps/
make lua hiredis linenoise

cd ..
make

编译成功后,把程序导入eclipse CDT环境进行运行调试。导入后需要重新构建一下,不然调试的时刻会按照/cygwin的路径来查找源码。

  • Import,然后选择C/C++目录下的[Existing Code as Makefile project]
  • 在[Existing Code Location]填入redis程序对应的目录,在[Toolchain for Indexer Settings]选择Cygwin GCC
  • 导入完成后,右键选择[Build Configuration]->[Build All]
  • Run然后选择执行redis-server即可。

好像也可以远程调试

1
[root@Frankzfz]$gdbserver 10.27.10.48:9000 ./test_seg_fault

参考

Comments