mac下安装php zookeeper扩展
安装步骤
php-zookeeper依赖libzookeeper,所以需要先安装libzookeeper
安装libzookeeper
cd /usr/local/src/
wget http://mirror.bit.edu.cn/apache/zookeeper/stable/zookeeper-3.4.12.tar.gz
tar -xf zookeeper-3.4.12.tar.gz
cd zookeeper-3.4.12/src/c
./configure -prefix=/usr/local/zookeeper/zookeeper-3.4.12/
make && make install
安装php zookeeper扩展
cd /usr/local/src/
wget https://pecl.php.net/get/zookeeper-0.5.0.tgz
tar zxvf zookeeper-0.5.0.tgz
cd zookeeper-0.5.0
phpize
./configure –with-php-config=/usr/local/php/bin/php-config –with-libzookeeper-dir=/usr/local/zookeeper/zookeeper-3.4.12/
make && make install
修改php.ini,新增extension=zookeeper.so,然后重启php
vim /usr/local/etc/php/7.0/php.ini
; Directory in which the loadable extensions (modules) reside.
; http://php.net/extension-dir
extension_dir = "/usr/local/lib/php/pecl/20151012"
; On windows:
; extension_dir = "ext"
extension=zookeeper.so
遇到的问题
无论是安装libzookeeper还是安装php zookeeper扩展,在执行make && make install命令时会出现类似下面错误。网上查找了很大资料,都没这方面的解决方案,貌似只有在mac下才会有这样的问题。
/Library/Developer/CommandLineTools/usr/bin/make all-am
/bin/sh ./libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I./include -I./tests -I./generated -Wall -Werror -g -O2 -D_GNU_SOURCE -MT zookeeper.lo -MD -MP -MF .deps/zookeeper.Tpo -c -o zookeeper.lo `test -f 'src/zookeeper.c' || echo './'`src/zookeeper.c
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I./include -I./tests -I./generated -Wall -Werror -g -O2 -D_GNU_SOURCE -MT zookeeper.lo -MD -MP -MF .deps/zookeeper.Tpo -c src/zookeeper.c -fno-common -DPIC -o .libs/zookeeper.o
In file included from src/zookeeper.c:37:
/usr/local/include/string.h:49:1: error: unknown type name 'HASHKIT_API'
HASHKIT_API
^
/usr/local/include/string.h:50:1: error: expected identifier or '('
void hashkit_string_free(hashkit_string_st *ptr);
^
/usr/local/include/string.h:53:1: error: unknown type name 'HASHKIT_API'
HASHKIT_API
^
/usr/local/include/string.h:54:7: error: expected ';' after top level declarator
size_t hashkit_string_length(const hashkit_string_st *self);
^
/usr/local/include/string.h:56:1: error: unknown type name 'HASHKIT_API'
HASHKIT_API
^
/usr/local/include/string.h:57:1: error: expected identifier or '('
const char *hashkit_string_c_str(const hashkit_string_st* self);
^
src/zookeeper.c:505:19: error: implicitly declaring library function 'strdup' with type 'char *(const char *)'
[-Werror,-Wimplicit-function-declaration]
char *hosts = strdup(zh->hostname);
^
src/zookeeper.c:505:19: note: include the header <string.h> or explicitly provide a declaration for 'strdup'
src/zookeeper.c:524:10: error: implicit declaration of function 'strtok_r' is invalid in C99
[-Werror,-Wimplicit-function-declaration]
host=strtok_r(hosts, ",", &strtok_last);
^
src/zookeeper.c:524:9: error: incompatible integer to pointer conversion assigning to 'char *' from 'int'
[-Werror,-Wint-conversion]
host=strtok_r(hosts, ",", &strtok_last);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/zookeeper.c:526:27: error: implicitly declaring library function 'strrchr' with type
'char *(const char *, int)' [-Werror,-Wimplicit-function-declaration]
char *port_spec = strrchr(host, ':');
^
src/zookeeper.c:526:27: note: include the header <string.h> or explicitly provide a declaration for 'strrchr'
src/zookeeper.c:604:9: error: implicitly declaring library function 'memset' with type
'void *(void *, int, unsigned long)' [-Werror,-Wimplicit-function-declaration]
memset(&hints, 0, sizeof(hints));
^
src/zookeeper.c:604:9: note: include the header <string.h> or explicitly provide a declaration for 'memset'
src/zookeeper.c:640:49: error: implicitly declaring library function 'strerror' with type 'char *(int)'
[-Werror,-Wimplicit-function-declaration]
LOG_ERROR(("getaddrinfo: %s\n", strerror(errno)));
^
src/zookeeper.c:640:49: note: include the header <string.h> or explicitly provide a declaration for 'strerror'
src/zookeeper.c:669:17: error: implicitly declaring library function 'memcpy' with type 'void *(void *, const
void *, unsigned long)' [-Werror,-Wimplicit-function-declaration]
memcpy(addr, res->ai_addr, res->ai_addrlen);
^
src/zookeeper.c:669:17: note: include the header <string.h> or explicitly provide a declaration for 'memcpy'
src/zookeeper.c:681:14: error: incompatible integer to pointer conversion assigning to 'char *' from 'int'
[-Werror,-Wint-conversion]
host = strtok_r(0, ",", &strtok_last);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/zookeeper.c:849:20: error: implicitly declaring library function 'strchr' with type
'char *(const char *, int)' [-Werror,-Wimplicit-function-declaration]
index_chroot = strchr(host, '/');
^
src/zookeeper.c:849:20: note: include the header <string.h> or explicitly provide a declaration for 'strchr'
src/zookeeper.c:856:13: error: implicitly declaring library function 'strlen' with type
'unsigned long (const char *)' [-Werror,-Wimplicit-function-declaration]
if (strlen(zh->chroot) == 1) {
^
src/zookeeper.c:856:13: note: include the header <string.h> or explicitly provide a declaration for 'strlen'
src/zookeeper.c:862:24: error: implicitly declaring library function 'strncpy' with type 'char *(char *, const
char *, unsigned long)' [-Werror,-Wimplicit-function-declaration]
zh->hostname = strncpy(zh->hostname, host, (index_chroot - host));
^
src/zookeeper.c:862:24: note: include the header <string.h> or explicitly provide a declaration for 'strncpy'
src/zookeeper.c:932:5: error: implicitly declaring library function 'strcpy' with type
'char *(char *, const char *)' [-Werror,-Wimplicit-function-declaration]
strcpy(ret_str, zh->chroot);
^
src/zookeeper.c:932:5: note: include the header <string.h> or explicitly provide a declaration for 'strcpy'
src/zookeeper.c:933:12: error: implicitly declaring library function 'strcat' with type
'char *(char *, const char *)' [-Werror,-Wimplicit-function-declaration]
return strcat(ret_str, client_path);
^
src/zookeeper.c:933:12: note: include the header <string.h> or explicitly provide a declaration for 'strcat'
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make[1]: *** [zookeeper.lo] Error 1
make: *** [all] Error 2
解决方法
分析上面问题,基本是变量和一些string函数没有被显示声明。解决方法就是将没有定义的变量注释掉,将没有显示声明的函数补上。
重写/usr/local/include/string.h 文件如下,可以直接拷贝使用。然后重新执行make && make install,就可以了。
/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
*
* HashKit library
*
* Copyright (C) 2011-2012 Data Differential, http://datadifferential.com/
* Copyright (C) 2009-2010 Brian Aker All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
*
* * The names of its contributors may not be used to endorse or
* promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#pragma once
#ifdef __cplusplus
struct hashkit_string_st;
#endif
#ifdef __cplusplus
extern "C" {
#endif
/*
HASHKIT_API
void hashkit_string_free(hashkit_string_st *ptr);
HASHKIT_API
size_t hashkit_string_length(const hashkit_string_st *self);
HASHKIT_API
const char *hashkit_string_c_str(const hashkit_string_st* self);
*/
char *strdup(const char *s);
char *strtok_r(char *s, const char *delim, char **ptrptr);
char *strrchr(const char *, int);
void *memset(void *, int, unsigned long);
char *strerror(int);
void *memcpy(void *, const void *, unsigned long);
char *strchr(const char *, int);
unsigned long strlen(const char *);
char *strncpy(char *, const char *, unsigned long);
char *strcpy(char *, const char *);
char *strcat(char *, const char *);
int strncmp(const char *, const char *, unsigned long);
int strcmp(const char *, const char *);
void *memmove(void *, const void *, unsigned long);
int memcmp(const void *, const void *, unsigned long);
void *memchr(const void *, int, unsigned long);
#ifdef __cplusplus
} // extern "C"
#endif
mac下安装php zookeeper扩展的更多相关文章
- Mac下安装HBase及详解
Mac下安装HBase及详解 1. 千篇一律的HBase简介 HBase是Hadoop的数据库, 而Hive数据库的管理工具, HBase具有分布式, 可扩展及面向列存储的特点(基于谷歌BigTabl ...
- Mac 下安装Jenkins
Mac 下安装Jenkins 开始 Jenkins是一个基于Java开发的一种持续集成工具,用于建工持续重复的工作,功能包括: 持续的软件版本发布/测试项目 监控外部调用执行的工作. 近期打算搭建自动 ...
- mac 下安装mongodb
转载自https://segmentfault.com/a/1190000002547229 概念 MongoDB 是一个跨平台的,面向文档的数据库,提供高性能,高可用性和可扩展性方便. MongoD ...
- MAC下安装与配置MySQL
MAC下安装与配置MySQL MAC下安装与配置MySQL 一 下载MySQL 访问MySQL的官网http://www.mysql.com/downloads/ 然后在页面中会看到“MySQL ...
- Mac下安装UPnP Inspector
由于工作中需要用到UPnP Inspector这个工具,而这个工具在windows下安装非常简单,在Mac下安装却很麻烦,在此记录安装流程. 这个工具依赖于两个其他的库:Coherence(一个DLN ...
- Mac下安装Wireshark,双击闪退
Mac OS X上使用Wireshark抓包(http://blog.csdn.net/phunxm/article/details/38590561) Mac下安装Wireshark /Appli ...
- Mac下安装zshell
Mac 下安装zshell 什么是shell 大多数命令行用户接触最多的是Bash,因为Bash是各个版本操作系统(Linux&Mac)的默认shell. 查看当前使用的shell $ ech ...
- 【高可用HA】Apache (1) —— Mac下安装Apache Httpd到自定义路径(非/etc/apache2)
Mac下安装Apache Httpd httpd版本: httpd-2.4.17 参考来源: Tomcat Clustering - A Step By Step Guide Apache HTTP ...
- 《OD大数据实战》mac下安装nginx+php
一.mac安装nginx + php + php-fpm 或apache + php 1. Mac 下 Nginx.MySQL.PHP-FPM 的安装配置 2. Mac下安装LNMP(Nginx+P ...
随机推荐
- C# 获得对象的命名空间 ?.
A a = new A(); var t = a?.ToString(); //t = WebApplication1.Controllers.A //获得命名空间和类名 var t1 = (A)nu ...
- spring自定义注解实现登陆拦截器
1.spring自定义注解实现登陆拦截器 原理:定义一个注解和一个拦截器,拦截器拦截所有方法请求,判断该方法有没有该注解.没有,放行:有,要进行验证.从而实现方法加注解就需要验证是否登陆. 2.自定义 ...
- hadoop伪分布式平台搭建
1. 安装jdk1.7 JAVA_HOME=/home/hadoop/app/jdk1.7.0 vi /etc/profile.d CLASSPATH=.:$JAVA_HOME/lib/dt.jar: ...
- 我的Android案例签到日历
2015年的Android案例之旅 案例八:签到日历 知识点: GridView的使用SQLite的使用 涉及文件: res->layout->activity_main.xml 主布局文 ...
- java复制项目中的补丁,完整的包路径
package com.bytter.audit.iface.util; import java.io.BufferedInputStream; import java.io.BufferedOutp ...
- sqli-labs(24)
0x1 前言 SQL注入一般分为两类:一阶SQL注入(普通SQL注入),二阶SQL注入 .二次注入不是注入两次的意思,请不要混淆 0x2 什么是二阶注入 二阶注入是指客通过构造数据的形式,在浏览器或者 ...
- [CSP-S模拟测试]:666(模拟)
题目描述 不忘初心. 小$\pi$假期在家无聊,打开了某弹幕直播网站. 突然,有一个精彩的镜头. 小$\pi$看到了满屏的$6$,其中,有$666$.也有$666666$.也有$6666666666. ...
- GIT的安装和配置
- 实验报告三&&第五周总结
1.已知字符串:"this is a test of java".按要求执行以下操作:(要求源代码.结果截图.) ① 统计该字符串中字母s出现的次数. ② 统计该字符串中子串“is ...
- 微信小程序 API 数据缓存
微信小程序 数据缓存 (类似于 cookie) wx.setStorage() 将数据存储在本地缓存中制定的 key 中.会覆盖掉原来该 key 对应的内容,数据存储生命周期跟小程序本身一致,即除用户 ...