编译swig接口后缺少符号

发布于 2024-07-11 14:55:30 字数 2451 浏览 11 评论 0原文

我试图为我的linux共享对象编译一个php接口,并且我已经设法使用swig的输出让它编译得很好,但是当我尝试加载它时,它抱怨缺少符号:

error: undefined symbol: zend_register_long_constant

现在我看了一下在zend,它似乎是一个php框架。 我想我缺少一个可以链接的库,但我不知道哪个库。

之前还有其他人这样做过并让它发挥作用吗?

编辑:

 ldd xxxx.so 
    linux-gate.so.1 =>  (0xb7fdb000)
    libcurl-gnutls.so.4 => /usr/lib/libcurl-gnutls.so.4 (0xb7f0a000)
    libboost_date_time-gcc42-1_34_1.so.1.34.1 => /usr/lib/libboost_date_time-gcc42-1_34_1.so.1.34.1 (0xb7efb000)
    libboost_thread-gcc42-mt-1_34_1.so.1.34.1 => /usr/lib/libboost_thread-gcc42-mt-1_34_1.so.1.34.1 (0xb7eed000)
    libboost_filesystem-gcc42-1_34_1.so.1.34.1 => /usr/lib/libboost_filesystem-gcc42-1_34_1.so.1.34.1 (0xb7ee1000)
    libcrypt.so.1 => /lib/tls/i686/cmov/libcrypt.so.1 (0xb7eaf000)
    libresolv.so.2 => /lib/tls/i686/cmov/libresolv.so.2 (0xb7e9b000)
    librt.so.1 => /lib/tls/i686/cmov/librt.so.1 (0xb7e92000)
    libxml2.so.2 => /usr/lib/libxml2.so.2 (0xb7d55000)
    libdl.so.2 => /lib/tls/i686/cmov/libdl.so.2 (0xb7d51000)
    libnsl.so.1 => /lib/tls/i686/cmov/libnsl.so.1 (0xb7d38000)
    libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0xb7c49000)
    libm.so.6 => /lib/tls/i686/cmov/libm.so.6 (0xb7c23000)
    libgcc_s.so.1 => /lib/libgcc_s.so.1 (0xb7c14000)
    libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0xb7ab5000)
    libidn.so.11 => /usr/lib/libidn.so.11 (0xb7a83000)
    libldap_r-2.4.so.2 => /usr/lib/libldap_r-2.4.so.2 (0xb7a41000)
    libkrb5.so.3 => /usr/lib/libkrb5.so.3 (0xb79af000)
    libk5crypto.so.3 => /usr/lib/libk5crypto.so.3 (0xb798b000)
    libcom_err.so.2 => /lib/libcom_err.so.2 (0xb7987000)
    libgssapi_krb5.so.2 => /usr/lib/libgssapi_krb5.so.2 (0xb795c000)
    libgnutls.so.26 => /usr/lib/libgnutls.so.26 (0xb78bf000)
    libtasn1.so.3 => /usr/lib/libtasn1.so.3 (0xb78ad000)
    libz.so.1 => /usr/lib/libz.so.1 (0xb7897000)
    libgcrypt.so.11 => /lib/libgcrypt.so.11 (0xb782e000)
    libpthread.so.0 => /lib/tls/i686/cmov/libpthread.so.0 (0xb7814000)
    /lib/ld-linux.so.2 (0xb7fdc000)
    liblber-2.4.so.2 => /usr/lib/liblber-2.4.so.2 (0xb7806000)
    libsasl2.so.2 => /usr/lib/libsasl2.so.2 (0xb77ee000)
    libkrb5support.so.0 => /usr/lib/libkrb5support.so.0 (0xb77e5000)
    libkeyutils.so.1 => /lib/libkeyutils.so.1 (0xb77e1000)
    libgpg-error.so.0 => /lib/libgpg-error.so.0 (0xb77dc000)

Im trying to compile a php interface for my linux shared object and i have managed to get it to compile all right using the output from swig, however when i try and load the so it complains of a missing symbol:

error: undefined symbol: zend_register_long_constant

Now i have had a look at zend and it seems to be a php framework. I think im missing a library to link against but i dont know which library.

Any one else done this before and got it to work?

Edit:

 ldd xxxx.so 
    linux-gate.so.1 =>  (0xb7fdb000)
    libcurl-gnutls.so.4 => /usr/lib/libcurl-gnutls.so.4 (0xb7f0a000)
    libboost_date_time-gcc42-1_34_1.so.1.34.1 => /usr/lib/libboost_date_time-gcc42-1_34_1.so.1.34.1 (0xb7efb000)
    libboost_thread-gcc42-mt-1_34_1.so.1.34.1 => /usr/lib/libboost_thread-gcc42-mt-1_34_1.so.1.34.1 (0xb7eed000)
    libboost_filesystem-gcc42-1_34_1.so.1.34.1 => /usr/lib/libboost_filesystem-gcc42-1_34_1.so.1.34.1 (0xb7ee1000)
    libcrypt.so.1 => /lib/tls/i686/cmov/libcrypt.so.1 (0xb7eaf000)
    libresolv.so.2 => /lib/tls/i686/cmov/libresolv.so.2 (0xb7e9b000)
    librt.so.1 => /lib/tls/i686/cmov/librt.so.1 (0xb7e92000)
    libxml2.so.2 => /usr/lib/libxml2.so.2 (0xb7d55000)
    libdl.so.2 => /lib/tls/i686/cmov/libdl.so.2 (0xb7d51000)
    libnsl.so.1 => /lib/tls/i686/cmov/libnsl.so.1 (0xb7d38000)
    libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0xb7c49000)
    libm.so.6 => /lib/tls/i686/cmov/libm.so.6 (0xb7c23000)
    libgcc_s.so.1 => /lib/libgcc_s.so.1 (0xb7c14000)
    libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0xb7ab5000)
    libidn.so.11 => /usr/lib/libidn.so.11 (0xb7a83000)
    libldap_r-2.4.so.2 => /usr/lib/libldap_r-2.4.so.2 (0xb7a41000)
    libkrb5.so.3 => /usr/lib/libkrb5.so.3 (0xb79af000)
    libk5crypto.so.3 => /usr/lib/libk5crypto.so.3 (0xb798b000)
    libcom_err.so.2 => /lib/libcom_err.so.2 (0xb7987000)
    libgssapi_krb5.so.2 => /usr/lib/libgssapi_krb5.so.2 (0xb795c000)
    libgnutls.so.26 => /usr/lib/libgnutls.so.26 (0xb78bf000)
    libtasn1.so.3 => /usr/lib/libtasn1.so.3 (0xb78ad000)
    libz.so.1 => /usr/lib/libz.so.1 (0xb7897000)
    libgcrypt.so.11 => /lib/libgcrypt.so.11 (0xb782e000)
    libpthread.so.0 => /lib/tls/i686/cmov/libpthread.so.0 (0xb7814000)
    /lib/ld-linux.so.2 (0xb7fdc000)
    liblber-2.4.so.2 => /usr/lib/liblber-2.4.so.2 (0xb7806000)
    libsasl2.so.2 => /usr/lib/libsasl2.so.2 (0xb77ee000)
    libkrb5support.so.0 => /usr/lib/libkrb5support.so.0 (0xb77e5000)
    libkeyutils.so.1 => /lib/libkeyutils.so.1 (0xb77e1000)
    libgpg-error.so.0 => /lib/libgpg-error.so.0 (0xb77dc000)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

花期渐远 2024-07-18 14:55:31

如果在链接阶段缺少库,则无法编译和链接它。

您能否 ldd 该共享对象并发布结果?

编辑:

构建时不会出现链接错误吗? 我相信那里应该有一个 libphp 的链接。

If you were missing a library during the link stage, you wouldn't have gotten it to compile and link.

Could you please ldd that shared object and post the results?

Edit:

You don't get a link error when you build? I believe there should be a link to libphp in there.

初吻给了烟 2024-07-18 14:55:31

从 ldd 输出来看,您似乎没有动态链接到 libphp。 这可能是 Swig 生成的 Makefile 的一个错误。

您可能想考虑使用正确的工具集来构建 PHP 扩展,而不是使用 Swig。 此过程因 PHP 版本而异。 这通常是从使用您正在使用的 PHP 发行版附带的工具“phpize”开始——这会根据您要构建的一组文件创建一个框架构建。

From the ldd output, it looks like you're not linking to libphp dynamically. It may be a bug with the Swig-generated Makefile.

You might want to look into using the correct toolset for building PHP extensions instead of using Swig. This process varies from version to version of PHP. This usually starts though with using the tool 'phpize' that comes with the PHP distribution you're using -- this creates a skeleton build from a set of files that you're going to be building from.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文