カラクリスタ

「輝かしい青春」なんて失かった人のブログ

Cygwin環境にmemcachedをインストールしてみた

æ¦è¦: Cygwin 㧠memcached ãã³ã³ãã¤ã«ãã¦ã¤ã³ã¹ãã¼ã«ãã


å人çã«ä½ã£ã¦ãã©ã¤ãã©ãªç¾¤(Applishã®ãã¨ã§ãã詳ãã㯠åã®ãªãã¸ããªåç§ ) ã®ã­ã£ãã·ã¥ã¯ã©ã¹ã§ã memcached ã使ã£ãã¯ã©ã¹ãä½ã£ã¦ã¦ã å®éã«åããã¦ãã¹ããã¦ã¿ããã£ããã§ãCygwin ã« memcached ãã¤ã³ã¹ãã¼ã«ãã¦ã¿ã¾ããã

ä»åã¯ãããªããããã¨æããããã½ã¼ã¹ã³ã¼ãã«ããããå½ã¦ãå¿è¦ããã£ãã®ã§ã ããã辺ãã¾ã¨ãã¦æ²è¼ãã¦ã¿ãã

1. ã½ã¼ã¹ã³ã¼ãã®åå¾

$ cd ~/tmp
$ wget http://memcached.googlecode.com/files/memcached-1.4.5.tar.gz

2. libeventã®ã¤ã³ã¹ãã¼ã«

memcached ã®åä½ã«ã¯ libevent ãå¿è¦ãªã®ã§ã åã«libeventãã¤ã³ã¹ãã¼ã«ãã¾ãã

ãã£ã¡ã¯å²ãã¨ãããªããã£ã¦ã

$ wget http://monkey.org/~provos/libevent-1.4.14b-stable.tar.gz
$ tar zxvf libevent-1.4.14b-stable.tar.gz
$ cd libevent-1.4.14b-stable
$ ./configure --prefix=/usr/local/libevent
$ make
$ make install

ã§ã¤ã³ã¹ãã¼ã«ãçµäºãã¾ãããã§ããã¨./configureã®ãªãã·ã§ã³ã«ã¤ãã¦ã¯åèªã§èª¿æ´ãã¦ãã ããã

3. memcachedã®ã½ã¼ã¹ã³ã¼ã修正

ã§ã次ã«memcachedã«ã½ã¼ã¹ã³ã¼ã修正ã«è¡ãã¾ãã

ã¾ããæåãutil.cã§ãmemcachedã®çã®ã³ã¼ãã ã¨ã Cygwin 㨠Solaris ã§åé¡ãçºçããã¿ããã§ãã詳ãã㯠Issue 111: compile errors: array subscript has type 'char' ãåç§ã

ã§ããã®åé¡ã«ã¤ãã¦ã¯ãåã®ãªã³ã¯åã§ãå人çã«ä¿®æ­£ãã¦ãã人ãããã®ã§ã ãããããã¯ã£ã¦ãã¾ãã正確ã«ã¯ã

ã®ãªãã¸ããªã®util.cã§ãmemcachedã®util.cãä¸æ¸ãããã° OK ã§ãã

ã§ãä»åº¦ã¯testapp.cã®ä¿®æ­£ããã¾ãã

testapp.cã«ã¤ãã¦ãªãã§ããããã®ãã¡ã¤ã«ã¯ã³ã³ãã¤ã«æã«ã

testapp.c: In function 'cache_redzone_test':
testapp.c:125: error: unknown field 'sa_handler' specified in initializer
cc1: warnings being treated as errors

ã¿ãããªã¨ã©ã¼ãåãã¾ãã

ã§ãã®ã¨ã©ã¼ã¡ãã»ã¼ã¸ã®unknown field 'sa_handler' specified in initializer 㧠Google æ¤ç´¢ãããä¸çºã§åºã¦ãããã§ãããã©ãããã®ã¨ã©ã¼ã¯ãCygwin ã®ããããã¡ã¤ã«ã®é½åä¸ãããããã§ãã

ã¾ãåã¯è©³ãããã¨ã¯åãããªããã§è©³ç´°ã¯ Designated Initializer - BOOLEANLABEL ãåç§ãã¦ãã ããã

ã§ãªã³ã¯åã§ã

sahandler ãããã«åé¨ã§ union ã®ã¡ã³ãã«ãªã£ã¦ããããã¨ãããªãã§ãããã¡ãªã¿ã«æ®éã«ã¡ã³ãã«ä»£å¥ããããã«æ¸ãã¨ãã³ã³ãã¤ã«ã§ããã®ã¯ä½æãªã®ã ããã? *1code:

include <signal.h>

void func(void) { struct sigaction action; action.sa_handler = SIG_IGN; action.sa_flags = 0; }

ã¨è¿°ã¹ããã¦ããããã«ãåé¡ã®ç®æãä¸è¨ã®ããã«æ¸ãæããã°ã ã³ã³ãã¤ã«ã¯å¯è½ã«ãªãããã§ãã

ã§ãtestapp.cã®åé¡ã®ç®æ㯠line 125 ã®ã

code:_ struct sigaction action = .sahandler = SIGIGN, .sa_flags = 0;

ã¨ãªã£ã¦ããã¨ãããã

struct sigaction action;
action.sa_handler  = SIG_IGN;
action.sa_flags    = 0;

ã¨æ¸ãæããã° OK ã§ãã

4. memcachedã®ã³ã³ãã¤ã«

ããã§memcachedã®ã½ã¼ã¹ã®ä¿®æ­£ã¯çµãã£ãã®ã§ããã¨ã¯ç«¯æ«ã§ã

$ cd ~/tmp/memcached-1.4.5
$ ./configure --prefix=/usr/local/memcached --with-libevent=/usr/local/libevent
$ make
$ make test
$ make install

ããã° Cygwin ã«memcachedãã¤ã³ã¹ãã¼ã«ã§ãã¾ãã

ã¡ãªã¿ã«å㯠memcached ã®åä½ç¢ºèªãããã®ã«make testãããã£ã¦ãªãã®ã§ã æ¬çªç°å¢ã§æ¬å½ã«åããã©ããã¯ç¢ºèªã§ãã¦ãã¾ããã

ã¾ãmake testã§ãã¹ããããããããªãã¨ã¯ãªãã£ãã®ã§ãå¤å大ä¸å¤«ã§ãããã

ã¨ããããã§ä»¥ä¸ã§memcachedã®ã¤ã³ã¹ãã¼ã«ã¯çµããã§ãã

5. 以ä¸çµäºã以ä¸ææ³

ã¾ãä»åmemcachedãå®éã«ã¤ã³ã¹ãã¼ã«ãã¦ã¿ãããã§ããã è©°ã¾ã£ãç®æãèªåã§ãªãã¨ãã§ããç¯å²ã ã£ãã®ã幸ãã§ããã ããã§ããã®åãããã¨ã©ã¼ã¨ããã½ã¼ã¹ã大å¹ã«æ¸ãæããªãã¨ãã¡ãªç®æã¨ãåºã¦ãããã å¤åãæä¸ãã ã£ãã§ãããã ã¾ãããã§memcachedã¯æã«å¥ã£ãã®ã§ããã¨ã¯memcachedã使ããã¹ããæ¸ãã ãã§ãã

ã¨ããããã§ãä»æ¥ã¯ Cygwin ã«memcachedãã¤ã³ã¹ãã¼ã«ãã¦ã¿ãã¨ããã話ã§ããã

FIXME