【问题标题】:How can I install libmemcached for Mac OS X Yosemite 10.10 in order to install the memcached.so PHP extension on Mamp 3?如何为 Mac OS X Yosemite 10.10 安装 libmemcached 以便在 Mamp 3 上安装 memcached.so PHP 扩展?
【发布时间】:2014-11-18 21:11:56
【问题描述】:

我需要在运行 Mac OS X Yosemite 的 MacBook Pro 上安装 libmemcached。

我已经安装了 memcached 守护进程,但是为了使 PHP memcached.so PECL 扩展能够工作,我需要安装 libmemcached。

我已经从 https://launchpad.net/libmemcached/+download 下载了 tar.gz,查看了文件 README.FIRST:

Hi!

If you are getting this code from http://launchpad.net/libmemcached then
continue reading. Otherwise these directions are not for you (well maybe...).

To obtain code from http://bazaar.launchpad.net/libmemcached you will need to
issue the following command:

bzr branch lp:libmemcached

Once the tree is cloned you will need to build the "configure" script. You
can do this by running the script:

./bootstrap.sh autoreconf

It will set up all of the files you need to build libmemcached. At that
point it is just the typical "./configure; make; make test; make install"

For a tarball release do a "make dist" and for an RPM type "make rpm".

For patches, we prefer you push a branch to launchpad and then submit that 
branch to be merged. For more information, see:

https://help.launchpad.net/Code/UploadingABranch
https://help.launchpad.net/Code/Review

Thanks and keep hacking!

Cheers,
  -Brian
  Seattle, WA.

所以我已经安装了 Bazaar,然后输入了以下命令:

bzr branch lp:libmemcached

但我得到的是:

    bzr: warning: unsupported locale setting
  bzr could not set the application locale.
  Although this should be no problem for bzr itself, it might
  cause problems with some plugins. To investigate the issue,
  look at the output of the locale(1p) tool.
Not checking SSL certificate for xmlrpc.launchpad.net.
You have not informed bzr of your Launchpad ID, and you must do this to
write to Launchpad or access private data.  See "bzr help launchpad-login".
bzr: ERROR: Target directory "libmemcached" already exists.  

如果我尝试运行 ./configure 然后 make,我会收到很多警告,例如:

./libmemcached/server.hpp:82:62: warning: implicit conversion loses integer precision: 'uint64_t'
  (aka 'unsigned long long') to 'uint32_t' (aka 'unsigned int') [-Wshorten-64-to-32]

libmemcached/csl/scanner.cc:2070:2: warning: 'register' storage class specifier is deprecated
      [-Wdeprecated-register]

libmemcached/byteorder.cc:75:10: error: use of undeclared identifier 'htonll'

还有 2 个错误:

2 errors generated.
make[1]: *** [libmemcached/libmemcached_libmemcached_la-byteorder.lo] Error 1
make: *** [all] Error 2

所以实际上我无法安装 libmemcached。有什么我可以尝试的选项,我该如何解决这个问题?为什么会出现这些错误?

感谢关注!

希望得到一些帮助。

【问题讨论】:

    标签: php macos memcached libmemcached


    【解决方案1】:

    通过更改配置脚本和源文件之一,我设法让 libmemcached 在 OSX 10.10.3 上编译和安装。

    configure我改了行:

    if ac_fn_cxx_try_compile "$LINENO"; then :
        ac_cv_have_htonll=yes
    else
        ac_cv_have_htonll=no
    fi
    

    到:

    ac_cv_have_htonll=no
    

    然后在clients/memflush.cc 我改变了2个实例:

    if (opt_servers == false)
    

    到:

    if (opt_servers == NULL)
    

    之后,通常的configuremakesudo make install 工作正常(尽管有很多警告)。然后该库似乎可以正常工作,在我的情况下使用 pylibmc。

    【讨论】:

    • 谢谢! 10.11.2上成功编译libmemcached
    【解决方案2】:

    我知道这个问题是很久以前提出的,但我认为问题出在其他地方,即缺少包含。

    这就是我在 (macOS High Sierra 10.13) 上解决问题的方法:

    在 bytesorder.cc 中,我在 byteorder.h 之后添加了这 3 行:

    #if defined HAVE_HTONLL && defined HAVE_SYS_TYPES_H
    #include <sys/types.h>
    #endif
    

    【讨论】:

    • 谢谢,这对我有用! (加上第一个答案中提到的if (opt_servers == NULL)
    猜你喜欢
    • 2015-01-16
    • 2016-05-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-07-24
    • 1970-01-01
    • 2014-09-02
    • 2015-01-28
    相关资源
    最近更新 更多