当前位置: 移动技术网 > 网络运营>服务器>Linux > Gearman::XS在Centos下的编译安装方法

Gearman::XS在Centos下的编译安装方法

2017年12月12日  | 移动技术网网络运营  | 我要评论

本文简述了gearman::xs在centos下编译安装方法,供大家参考学习一下!

目前gearman能够支持各种语言,其官网的描述如下:
 

language bindings/drivers/frameworks
select your language – cross links to download section which details all your options.
c, c#/.net, go, java, lisp, nodejs, php, perl, python, ruby, database udfs.

 
个人尝试了c、python、perl三种语言的api,感觉perl的api功能相对来说齐全一点。gearman::xs是perl的开源支持。其链接如下:http://search.cpan.org/~krow/gearman-xs/

在rhel5.7下安装的gearman::xs,中间会出现各种问题,此处给出这些问题的解决方法供大家参考。

首先,我使用了cpanm来安装gearman::xs,结果如下:

[@localhost yunfei]# cpanm gearman::xs
--> working on gearman::xs
fetching http://www.cpan.org/authors/id/k/kr/krow/gearman-xs-0.15.tar.gz ... ok
configuring gearman-xs-0.15 ... ok
building and testing gearman-xs-0.15 ... fail
! installing gearman::xs failed. see /root/.cpanm/work/1392343258.18128/build.log for details. retry with --force to force install it.

显然force强制安装肯定是不行的,所以就找原因。查看 /root/.cpanm/work/1392343258.18128/build.log文件,发现其中有如下的提示:

gcc -c -wall -wundef -wno-shadow -wmissing-prototypes -fdiagnostics-show-option -wformat=2 -wstrict-aliasing -wextra -wmissing-declarations -wcast-align -wswitch-default -wswitch-enum -wno-undef -wno-unused-value -wno-unused-variable -wno-unused-parameter -wno-format-invalid-specifier -o2 -g -pipe -wall -wp,-d_fortify_source=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -dversion=\"0.15\" -dxs_version=\"0.15\" -fpic "-i/usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/core" xs.c
cc1: error: unrecognized command line option "-wno-format-invalid-specifier"
make: *** [xs.o] error 1
-> fail installing gearman::xs failed.

看到是在编译的时候出了问题,所以,咱们切换到它的编译目录(即 /root/.cpanm/work/1392343258.18128/这个目录)

cd /root/.cpanm/work/1392343258.18128/gearman-xs-0.15

然后执行make命令,就可以看到上面报的编译错误了。ok,下面就着手解决它。

vi makefile

可以找到:

ccflags = -wall -wundef -wno-shadow -wmissing-prototypes -fdiagnostics-show-option -wformat=2 -wstrict-aliasing -wextra -wmissing-declarations -wcast-align -wswitch-default -wswitch-enum -wno-undef -wno-unused-value -wno-unused-variable -wno-unused-parameter -wno-format-invalid-specifier

删掉最后的“-wno-format-invalid-specifier”这个选项,然后保存退出,再次执行make。
 
会发现报出如下错误:

in file included from xs.xs:11:
gearman_xs.h:18:36: error: libgearman-1.0/gearman.h: no such file or directory
xs.c: in function 'xs_gearman__xs_strerror':
xs.c:229: error: 'gearman_return_t' undeclared (first use in this function)
xs.c:229: error: (each undeclared identifier is reported only once
xs.c:229: error: for each function it appears in.)
xs.c:229: error: expected ';' before 'rc'
xs.xs:82: warning: implicit declaration of function 'gearman_strerror'
xs.xs:82: error: 'rc' undeclared (first use in this function)
xs.xs:82: warning: assignment makes pointer from integer without a cast
make: *** [xs.o] error 1

很明显,是找不到gearman.h,也就是说需要gearman-devel,正常情况下通过yum直接安装gearman-devel包就可以解决这个问题,但是,我的rhel是手动安装的gearman-1.1.11版本,和yum安装的版本不一致,所以,再次打开并修改makefile。

找到inc以及lddlflags,修改为如下内容:

lddlflags = -shared -o2 -g -pipe -wall -wp,-d_fortify_source=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -l/usr/local/gearman/lib/ -lgearman
 
inc = -i/usr/local/gearman/include/ -l/usr/local/gearman/lib/

可以看到就是加入了gearman的incule以及lib相关的东西。保存退出makefile,再次执行make,顺利通过,然后make install就安装完毕了。

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网