php - 在 Ubuntu 上编译 PHP 扩展库 (Karmic Koala)

标签 php c++ c ubuntu php-extension

不久前,我在我的 XP 平台上编译了一些 PHP 扩展库(使用 C/C++)。我现在已将源代码移至我的 Ubuntu 机器,并希望构建库以在我的 Linux 机器上使用。

但是,我遇到了一些障碍:

  1. 我找不到 phpize(即使安装了 php5dev 包之后)
  2. 我找不到 ext_skel 来生成骨架脚本/文件

[编辑]

感谢 Pascal Martin 和 this question ,我已经设法构建并测试了我的一个较小的库。在继续使用其他库之前,我只想仔细检查我的 .m4 文件的内容(因为我不熟悉这种格式)。

这是自动生成的 .m4 文件的内容 - 是否有人熟悉这种格式,他们能解释一下它的含义吗 - 这样我就可以加倍确定我取消了文件中正确部分的注释。

config.m4 文件的内容显示在下面的所有详细信息中:

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 生成的(我也刚刚看到文档 here 并且正在慢慢消化它。

最佳答案

在我的 Ubuntu 计算机上,phpize 位于:

$ which phpize
/usr/bin/phpize


并且 ext_skel 应该在“ext”目录中,在 PHP 源代码中,您可以通过 SVN 获取它。

这是 ext 目录:http://svn.php.net/viewvc/php/php-src/trunk/ext/
并且可以查看脚本内容here .

README.EXT_SKEL就在 trunk/ 下。


如果你更喜欢 git 用户,github 上有一个 SVN 的镜像:http://github.com/php/

关于php - 在 Ubuntu 上编译 PHP 扩展库 (Karmic Koala),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2267698/

相关文章:

c - 我在 C 中的随机字符串生成器不起作用

c - 在下面的伪 C 代码片段中避免重复代码的方法应该是什么?

Php 说找不到已经包含的类

php - 如何在页面上查询 Woocommerce 订单

如果我不打印,char * 会消失吗?

c++ - float 不准确导致计算错误

c++ - 使用 Wt C++ 框架的经验?

javascript - 如何防止 PHP sleep 函数停止我的 HTML 页面

php - Cakephp 应用程序在 ec2 上显示不正确的路径

c++ - 是否有用于 C++ quickfix 的 MessageCodeGenerator?