CentOS6.3编译安装Memcached集群分布式缓存代理Magent-0.6出错汇总

参考文章:Memcached集群/分布式/高可用 及 Magent缓存代理搭建过程 详解,搭建Magent,在编译的过程中会出现很多错误:

#编译安装安装magent到 /usr/local/magent 下

cd /usr/local/
mkdir ./magent
cd ./magent
wget -c http://memagent.googlecode.com/files/magent-0.6.tar.gz
tar xzvf ./magent-0.6.tar.gz
/sbin/ldconfig
sed -i "s#LIBS = -levent#LIBS = -levent -lm#g" Makefile
make
cp ./magent /usr/bin/magent

 

执行到 make 的时候,

报错1:

gcc -Wall -g -O2 -I/usr/local/include -m64 -c -o magent.o magent.c
magent.c: In function 'writev_list':
magent.c:729: error: 'SSIZE_MAX' undeclared (first use in this function)
magent.c:729: error: (Each undeclared identifier is reported only once
magent.c:729: error: for each function it appears in.)
make: *** [magent.o] Error 1

解决方案:

vim ./ketama.h 
#在开头加入
#ifndef SSIZE_MAX
#define SSIZE_MAX      32767
#endif

继续make

报错2:

gcc -Wall -g -O2 -I/usr/local/include -m64 -c -o magent.o magent.c
gcc -Wall -g -O2 -I/usr/local/include -m64 -c -o ketama.o ketama.c
gcc -Wall -g -O2 -I/usr/local/include -m64 -o magent magent.o ketama.o /usr/lib64/libevent.a /usr/lib64/libm.a 
gcc: /usr/lib64/libevent.a: No such file or directory
gcc: /usr/lib64/libm.a: No such file or directory

解决办法:

ln -s /usr/lib/libevent*  /usr/lib64/

继续make

报错3:

gcc -Wall -g -O2 -I/usr/local/include -m64 -o magent magent.o ketama.o /usr/lib64/libevent.a /usr/lib64/libm.a 
gcc: /usr/lib64/libm.a: No such file or directory
make: *** [magent] Error 1

解决办法:

yum install -y glibc glibc-devel 

如果是64bit的系统则不会在/usr/lib64/libm.a 生成,如果是32bit即会有。所以,在64位机器中,还必须:

\cp /usr/lib64/libm.so /usr/lib64/libm.a

继续make

报错4:

gcc -Wall -g -O2 -I/usr/local/include -m64 -o magent magent.o ketama.o /usr/lib64/libevent.a /usr/lib64/libm.a 
/usr/lib64/libevent.a(event.o): In function `detect_monotonic':
event.c:(.text+0xc79): undefined reference to `clock_gettime'
/usr/lib64/libevent.a(event.o): In function `gettime':
event.c:(.text+0xd60): undefined reference to `clock_gettime'
collect2: ld returned 1 exit status
make: *** [magent] Error 1

解决办法:

vim ./Makefile

CFLAGS = -Wall -g -O2 -I/usr/local/include $(M64)
改为:    
CFLAGS = -lrt -Wall -g -O2 -I/usr/local/include $(M64) 

继续make

make 
\cp magent /usr/bin/magent 

 


 

最后,安装汇总:

1、在ketama.h中加入 

vim ./ketama.h 

#ifndef SSIZE_MAX 
#define SSIZE_MAX 32767 
#endif 

2、安装依赖库

yum install -y glibc-devel 
\cp /usr/lib64/libm.so /usr/lib64/libm.a 
ln -s /usr/lib/libevent* /usr/lib64/ 

3、编辑Makefile 

vim ./Makefile 

CFLAGS = -Wall -g -O2 -I/usr/local/include $(M64) 
修改为 
CFLAGS = -lrt -Wall -g -O2 -I/usr/local/include $(M64) 

4、重新编译

/sbin/ldconfig 
sed -i "s#LIBS = -levent#LIBS = -levent -lm#g" Makefile 
make 
\cp magent /usr/bin/magent 

 

posted @ 2016-07-16 11:22  52php  阅读(715)  评论(0编辑  收藏  举报