调试 SWIG PHP 扩展:未定义符号:_ZN15SplashOutputDev9updateAllEP8GfxState

发布于 2024-12-11 08:52:51 字数 2107 浏览 0 评论 0原文

我刚刚重新安装了我的服务器,从 Ubuntu 11.04 切换到 11.10,从 32 位切换到 64 位。之后我尝试重新安装我的自定义 SWIG PHP 扩展。

我编译了

swig -I/usr/local/include/poppler -Wall -php -c++ popplig.i
g++ -g -I. -I/usr/local/include/poppler -I/usr/include/php5 -I/usr/include/php5/main -I/usr/include/php5/TSRM -I/usr/include/php5/Zend -I/usr/include/php5/ext -I/usr/include/php5/ext/date/lib -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fpic -c popplig_wrap.cpp ExtensibleOutputDev.cc PDFFont.cc HtmlLinks.cc PDFImage.cc MarkedContentState.cc Error.cc
g++ -Wall -Wextra -g -lpoppler -shared popplig_wrap.o ExtensibleOutputDev.o PDFFont.o HtmlLinks.o PDFImage.o MarkedContentState.o Error.o -o popplig.so

链接完成,没有错误或警告。

但是当我运行 php 时,我得到

$ php -r ""
PHP Warning:  PHP Startup: Unable to load dynamic library '/atlas/www/txtbear/poppler-swig/popplig.so' - /atlas/www/txtbear/poppler-swig/popplig.so: undefined symbol: _ZN15SplashOutputDev9updateAllEP8GfxState in Unknown on line 0

This symbol is Define in my copy of libpoppler

$ nm -g /usr/local/lib/libpoppler.so | grep _ZN15SplashOutputDev9updateAllEP8GfxState
0000000000141370 T _ZN15SplashOutputDev9updateAllEP8GfxState

ld Knows about poppler

$ sudo ldconfig -v | grep poppler
    libpoppler-cpp.so.0 -> libpoppler-cpp.so.0.1.0
    libpoppler.so.6 -> libpoppler.so.6.0.0
    libpoppler.so.6 -> libpoppler.so.6.0.0
    libpoppler-glib.so.6 -> libpoppler-glib.so.6.0.0

But my extension isn't似乎链接到它(尽管有 -lpoppler

$ ldd popplig.so
    linux-vdso.so.1 =>  (0x00007fffbd079000)
    libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fa104957000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fa1046d3000)
    libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fa1044bc000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fa10411d000)
    /lib64/ld-linux-x86-64.so.2 (0x00007fa10502b000)

所以看来是问题在于 g++ 没有链接到 libpoppler。我怎样才能找出链接出了什么问题?

I just reinstalled my server, switching from Ubuntu 11.04 to 11.10 and from 32 to 64-bit. Afterwards I tried to reinstall my custom SWIG PHP extension.

I compiled with

swig -I/usr/local/include/poppler -Wall -php -c++ popplig.i
g++ -g -I. -I/usr/local/include/poppler -I/usr/include/php5 -I/usr/include/php5/main -I/usr/include/php5/TSRM -I/usr/include/php5/Zend -I/usr/include/php5/ext -I/usr/include/php5/ext/date/lib -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fpic -c popplig_wrap.cpp ExtensibleOutputDev.cc PDFFont.cc HtmlLinks.cc PDFImage.cc MarkedContentState.cc Error.cc
g++ -Wall -Wextra -g -lpoppler -shared popplig_wrap.o ExtensibleOutputDev.o PDFFont.o HtmlLinks.o PDFImage.o MarkedContentState.o Error.o -o popplig.so

The linking completes with no errors or warnings.

But when I run php I get

$ php -r ""
PHP Warning:  PHP Startup: Unable to load dynamic library '/atlas/www/txtbear/poppler-swig/popplig.so' - /atlas/www/txtbear/poppler-swig/popplig.so: undefined symbol: _ZN15SplashOutputDev9updateAllEP8GfxState in Unknown on line 0

This symbol is defined in my copy of libpoppler

$ nm -g /usr/local/lib/libpoppler.so | grep _ZN15SplashOutputDev9updateAllEP8GfxState
0000000000141370 T _ZN15SplashOutputDev9updateAllEP8GfxState

ld knows about poppler

$ sudo ldconfig -v | grep poppler
    libpoppler-cpp.so.0 -> libpoppler-cpp.so.0.1.0
    libpoppler.so.6 -> libpoppler.so.6.0.0
    libpoppler.so.6 -> libpoppler.so.6.0.0
    libpoppler-glib.so.6 -> libpoppler-glib.so.6.0.0

But my extension doesn't seem to be linked to it (despite the -lpoppler)

$ ldd popplig.so
    linux-vdso.so.1 =>  (0x00007fffbd079000)
    libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fa104957000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fa1046d3000)
    libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fa1044bc000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fa10411d000)
    /lib64/ld-linux-x86-64.so.2 (0x00007fa10502b000)

So it seems the problem lies with g++ not linking to libpoppler. How can I find out what is going wrong with the linking?

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

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

发布评论

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

评论(1

仅此而已 2024-12-18 08:52:51

g++ -Wall -Wextra -g -lpoppler -shared popplig_wrap.o...

此命令行不正确:库应该跟随在链接线上使用它们的对象。看看将 -lpoppler 移动到链接行的末尾是否会

  1. 使其显示在 ldd popplig.so 中并
  2. 修复未解决的符号问题。

g++ -Wall -Wextra -g -lpoppler -shared popplig_wrap.o...

This command line is incorrect: libraries are supposed to follow objects that use them on the link line. See if moving -lpoppler to the end of the link line will

  1. Make it show up in ldd popplig.so and
  2. Fix the unresolved symbol problem.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文