Question

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?

Was it helpful?

Solution

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.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top