gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 02:24:33 25 4
gpt4 key购买 nike

我正在尝试为 PHP 编写 C 扩展。这是我的 config.m4。直接从helloworld出来,差不多

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

当我运行 phpize 和 ./configure 时,它​​会生成一个可用的 Makefile。 到目前为止看起来不错。

现在,如果我向 PHP_NEW_EXTENSION 添加一个附加源文件,事情就会崩溃。根据 herehere ,调用应如下所示:

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

完整语法:

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

好的,所以我将额外的源文件 (logging.c) 添加到该列表中:

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

和 phpize/configure 生成一个成功运行但实际上没有构建任何东西的 Makefile。(是的,我已经完成了 make distclean、phpize --clean 等)

我比较了成功的 Makefile 与损坏的 Makefile,区别如下:

$ 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)
<

有人知道这是怎么回事吗?

顺便说一句,如果我遗漏了额外的源文件,我会收到关于该文件中函数具有“内部链接但未定义”的编译器警告。

最佳答案

尝试移动第二个逗号

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

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

如果我对文档的理解正确,第二个参数应该是以空格分隔的来源列表。

关于在 PHP_NEW_EXTENSION 中有多个源文件的 phpize 的 config.m4 生成一个什么都不做的 Makefile,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23945160/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com