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 ...
随机推荐
- 24.二叉树中和为某一值的路径(python)
题目描述 输入一颗二叉树的跟节点和一个整数,打印出二叉树中结点值的和为输入整数的所有路径.路径定义为从树的根结点开始往下一直到叶结点所经过的结点形成一条路径.(注意: 在返回值的list中,数组长度大 ...
- Lambda表达式匿名类实现接口方法
Lamb表达式匿名类实现接口方法 import java.util.ArrayList; public class HandlerDemo{ public static void main(Strin ...
- C# 自定义类中括号取值 测试
public class ABC : Hashtable{} static class Program { public static ABC a= new ABC(); static void Ma ...
- 线程优先级队列( Queue)
Python的Queue模块中提供了同步的.线程安全的队列类,包括FIFO(先入先出)队列Queue,LIFO(后入先出)队列LifoQueue,和优先级队列PriorityQueue.这些队列都实现 ...
- CF718C Sasha and Array 线段树 + 矩阵乘法
有两个操作: 将 $[l,r]$所有数 + $x$ 求 $\sum_{i=l}^{r}fib(i)$ $n=m=10^5$ 直接求不好求,改成矩阵乘法的形式: $a_{i}=M^x\times ...
- No 'Configuration' method was found in class 'WebApp.Startup
The following errors occurred while attempting to load the app.- No 'Configuration' method was found ...
- Luogu P5469 [NOI2019]机器人 (DP、多项式)
不用FFT的多项式(大雾) 题目链接: https://www.luogu.org/problemnew/show/P5469 (这题在洛谷都成绿题了海星) 题解: 首先我们考虑,一个序列位置最右边的 ...
- 使用node.js搭建本地服务器
第一步安装node:https://nodejs.org/zh-cn/download/ 接下来就需要安装http的镜像文件 打开cmd:输入以下命令 npm install http-server ...
- CNN中感受野的理解
本文摘自看完还不懂卷积神经网络“感受野”?那你来找我 作者:程序_小白链接:https://www.jianshu.com/p/9305d31962d8 一.到底什么是“感受野”(接受野Recepti ...
- 将Windows下的文件同步到Linux下
需求:把Windows下的某些文件自动传送到Linux指定目录下 实现: 1. Windows下安装 WinSCP工具,并把Liunx服务器信息保存 2. 编写脚本,实现双击工具就把Windows下的 ...