Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Compile Redis with Cygwin

Prerequisites

Install Cygwin with make, gcc, g++ and tcl.
(If you use apt-cyg you can install them with apt-cyg install make, apt-cyg install gcc-core and apt-cyg install tcl
Download Redis tar.gz package, unpack it.

Patch

Edit deps/hiredis/net.c and add following line before include directives:

#define _POSIX_C_SOURCE 200112L

and add the following lines just after the include directives:

/* Cygwin Fix */
#ifdef __CYGWIN__
#define TCP_KEEPCNT 8
#define TCP_KEEPINTVL 150
#define TCP_KEEPIDLE 14400
#endif

Build

Run the following script:

cd deps/
make lua hiredis linenoise

cd ..
make
# Some tests fail, but mainly working which is suitable for development environments
make test
make install

Test

# Check redis version
redis-cli --version

# Run redis server as deamon
redis-server &

# Test redis
redis-cli PING
# or
redis-cli -h localhost PING

Credits

Thanks to winse, see this blog entry and pcan https://gist.github.com/pcan/44cb2177647f029d457facb31da0883f).

@drnybble

This comment has been minimized.

Copy link

@drnybble drnybble commented Apr 25, 2019

I found another problem if you are using sentinels. You need to change a line in src/sentinel.c:

void sentinelFlushConfig(void) {
...
    if ((fd = open(server.configfile,O_RDONLY)) == -1) goto werr;
    if (fsync(fd) == -1) goto werr;

Change that to O_RDWR because the following fsync will fail on a read-only file descriptor. cygwin ultimately calls the Windows FlushFileBuffers API call that requires GENERIC_WRITE access or it fails with a Permission Denied error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment