dsz1966 2014-05-30 00:22
浏览 173
已采纳

phpize的config.m4在PHP_NEW_EXTENSION中有多个源文件会产生一个什么也不做的Makefile

I am trying to write a C extension to PHP. This is my config.m4. Straight out of helloworld, almost

PHP_ARG_ENABLE(my_ext, whether to enable my_ext support,
[ --enable-my-ext   Enable My Ext support])

if test "$PHP_MY_EXT" = "yes"; then
  AC_DEFINE(HAVE_MY_EXT, 1, [Whether you have my ext])
  PHP_NEW_EXTENSION(my_ext, my_ext.c,  $ext_shared)
fi

When I run phpize and ./configure, it generates a Makefile that works. Looking good so far.

Now, if I add an additional source file to PHP_NEW_EXTENSION, things break down. As per here and here, the call should look like:

PHP_NEW_EXTENSION(foo, foo.c bar.c baz.cpp, $ext_shared)

The full syntax:

PHP_NEW_EXTENSION(extname, sources [, shared [,sapi_class[, extra-cflags]]])

Ok, so I add my extra source file (logging.c) to that list:

PHP_NEW_EXTENSION(my_ext, my_ext.c, logging.c  $ext_shared)

and phpize/configure produce a Makefile that runs successfully, but does not actually build anything. (yes, I've done make distclean, phpize --clean, etc.)

I diffed the successful Makefile vs. the broken one, and here are the differences:

$ diff Makefile Makefile.broken 
14d13
< shared_objects_my_ext = my_ext.lo
16c15
< PHP_MODULES = $(phplibdir)/my_ext.la
---
> PHP_MODULES =
170,175d168
< $(phplibdir)/my_ext.la: ./my_ext.la
<   $(LIBTOOL) --mode=install cp ./my_ext.la $(phplibdir)
< 
< ./my_ext.la: $(shared_objects_my_ext) $(MY_EXT_SHARED_DEPENDENCIES)
<   $(LIBTOOL) --mode=link $(CC) $(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) $(LDFLAGS) -o $@ -export-dynamic -avoid-version -prefer-pic -module -rpath $(phplibdir) $(EXTRA_LDFLAGS) $(shared_objects_my_ext) $(MY_EXT_SHARED_LIBADD)
< 

Anyone know what is going on here?

BTW, if I leave out the extra source file, I get compiler warnings about functions in that file having "internal linkage but is not defined".

  • 写回答

1条回答 默认 最新

  • duanliao5995 2014-06-04 23:16
    关注

    Try moving the 2nd comma

    PHP_NEW_EXTENSION(my_ext, my_ext.c, logging.c $ext_shared)

    To

    PHP_NEW_EXTENSION(my_ext, my_ext.c logging.c, $ext_shared)

    If I understand the documentation correctly, the 2nd argument should be a space separated list of your sources.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 STM32 INMP441无法读取数据
  • ¥100 求汇川机器人IRCB300控制器和示教器同版本升级固件文件升级包
  • ¥15 用visualstudio2022创建vue项目后无法启动
  • ¥15 x趋于0时tanx-sinx极限可以拆开算吗
  • ¥500 把面具戴到人脸上,请大家贡献智慧
  • ¥15 任意一个散点图自己下载其js脚本文件并做成独立的案例页面,不要作在线的,要离线状态。
  • ¥15 各位 帮我看看如何写代码,打出来的图形要和如下图呈现的一样,急
  • ¥30 c#打开word开启修订并实时显示批注
  • ¥15 如何解决ldsc的这条报错/index error
  • ¥15 VS2022+WDK驱动开发环境