调试 SWIG PHP 扩展:未定义符号:_ZN15SplashOutputDev9updateAllEP8GfxState
我刚刚重新安装了我的服务器,从 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
此命令行不正确:库应该跟随在链接线上使用它们的对象。看看将 -lpoppler 移动到链接行的末尾是否会
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 willldd popplig.so
and