问题描述
不久前,我在 XP 平台上编译了一些 PHP 扩展库(在 C/C++ 中).我现在已经将源代码移到了我的 Ubuntu 机器上,并且想要构建在我的 Linux 机器上使用的库.
I compiled some PHP extention libs (in C/C++) a while back, on my XP platform. I have now moved the sources to my Ubuntu box, and want to build the libs for use on my Linux box.
但是,我遇到了许多障碍:
However, I have come accross a number of obstacles:
- 我找不到 phpize(即使在安装了 php5dev 包之后)
- 我找不到 ext_skel 来生成骨架脚本/文件
感谢 Pascal Martin 和 this question,我已经成功地构建并测试了我的一个较小的库.在继续使用其他库之前,我只想仔细检查我的 .m4 文件的内容(因为我不熟悉格式).
Thanks to Pascal Martin and this question, I have managed to build and test one of my smaller libraries. I just want to double check the contents of my .m4 file (since I am not familiar with the format), before I go ahead with the other libraries.
这是自动生成的 .m4 文件的内容 - 任何熟悉该格式的人,他们能否解释一下它的含义 - 这样我就可以加倍确定我已取消注释文件的正确部分.
This is the content of the autogenerated .m4 file - is anyone familiar with the format, and can they explain what it means - this is so that I can be doubly sure that I have uncommented the correct sections of the file.
config.m4 文件的内容在下面详细显示:
The contents of the config.m4 file are displayed below in all their gory detail:
dnl $Id$
dnl config.m4 for extension tanlib
dnl Comments in this file start with the string 'dnl'.
dnl Remove where necessary. This file will not work
dnl without editing.
dnl If your extension references something external, use with:
dnl PHP_ARG_WITH(tanlib, for tanlib support,
dnl Make sure that the comment is aligned:
dnl [ --with-tanlib Include tanlib support])
dnl Otherwise use enable:
PHP_ARG_ENABLE(tanlib, whether to enable tanlib support,
dnl Make sure that the comment is aligned:
[ --enable-tanlib Enable tanlib support])
if test "$PHP_TANLIB" != "no"; then
dnl Write more examples of tests here...
dnl # --with-tanlib -> check with-path
dnl SEARCH_PATH="/usr/local /usr" # you might want to change this
dnl SEARCH_FOR="/include/tanlib.h" # you most likely want to change this
dnl if test -r $PHP_TANLIB/$SEARCH_FOR; then # path given as parameter
dnl TANLIB_DIR=$PHP_TANLIB
dnl else # search default path list
dnl AC_MSG_CHECKING([for tanlib files in default path])
dnl for i in $SEARCH_PATH ; do
dnl if test -r $i/$SEARCH_FOR; then
dnl TANLIB_DIR=$i
dnl AC_MSG_RESULT(found in $i)
dnl fi
dnl done
dnl fi
dnl
dnl if test -z "$TANLIB_DIR"; then
dnl AC_MSG_RESULT([not found])
dnl AC_MSG_ERROR([Please reinstall the tanlib distribution])
dnl fi
dnl # --with-tanlib -> add include path
dnl PHP_ADD_INCLUDE($TANLIB_DIR/include)
dnl # --with-tanlib -> check for lib and symbol presence
dnl LIBNAME=tanlib # you may want to change this
dnl LIBSYMBOL=tanlib # you most likely want to change this
dnl PHP_CHECK_LIBRARY($LIBNAME,$LIBSYMBOL,
dnl [
dnl PHP_ADD_LIBRARY_WITH_PATH($LIBNAME, $TANLIB_DIR/lib, TANLIB_SHARED_LIBADD)
AC_DEFINE(HAVE_TANLIBLIB,1,[ Whether you have tanlib])
dnl ],[
dnl AC_MSG_ERROR([wrong tanlib lib version or lib not found])
dnl ],[
dnl -L$TANLIB_DIR/lib -lm -ldl
dnl ])
dnl
dnl PHP_SUBST(TANLIB_SHARED_LIBADD)
PHP_NEW_EXTENSION(tanlib, tanlib.c, $ext_shared)
fi
有人理解以上内容吗?
顺便说一句,上面的 config.m4 文件是使用 Autoconf 2.50 生成的(我也刚刚看到了文档 这里 正在慢慢消化.
BTW, the above config.m4 file was generated using Autoconf 2.50 (I have also just seen the documentation here and am slowly digesting it.
推荐答案
在我的 Ubuntu 计算机上,phpize 位于:
On my Ubuntu computer, phpize is in :
$ which phpize
/usr/bin/phpize
而ext_skel
应该在ext
"目录下,在PHP源代码中,你可以通过SVN获取.
And ext_skel
should be in the "ext
" directory, in the PHP sources, which you can get by SVN.
这是ext
目录:http://svn.php.net/viewvc/php/php-src/trunk/ext/
并且可以查看脚本的内容 这里.
README.EXT_SKEL
就在 trunk/
下.
如果你更像一个 git 用户,github 上有一个 SVN 的镜像:http://github.com/php/
这篇关于在 Ubuntu (Karmic Koala) 上编译 PHP 扩展库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!