Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Can't build QtPdf example with static Qt



  • Trying to build QtPdf (https://blog.qt.io/blog/2017/01/30/new-qtpdf-qtlabs-module/) example (pdfviewer) with static Qt 5.11.1 (compiled by myself), but receives error:

    /home/user/Downloads/qtpdf/lib/libqtpdfium.a(fpdfview.o):fpdfview.cpp:function FPDF_InitLibraryWithConfig: error: undefined reference to 'IJS_Runtime::Initialize(unsigned int, void*)'
    /home/user/Downloads/qtpdf/lib/libqtpdfium.a(fpdfview.o):fpdfview.cpp:function FPDF_DestroyLibrary: error: undefined reference to 'IJS_Runtime::Destroy()'
    

    There are such symbols in libqtpdfium.a file:

    nm /home/user/Downloads/qtpdf/lib/libqtpdfium.a | grep IJS_Runtime
             U _ZN11IJS_Runtime10InitializeEjPv
             U _ZN11IJS_Runtime7DestroyEv
             U _ZN11IJS_Runtime6CreateEP19CPDFDoc_Environment
    

    Have tried to build with command line, and in QtCreator - same result.
    With dynamic Qt (same version) everything is Ok.
    Static Qt kit is ok, I can build Qt examples with it.

    Compiler: g++ (GCC) 4.9.2 20150212 (Red Hat 4.9.2-6)
    OS: CentOS 6.10. Kernel: 2.6.32-754.15.3.el6.i686

    Thank you in advance



  • the simplest explanation is that your libqtpdfium.a libary isn't being added to the link stage correctly. what does the Qt generated link line look like when executed by command line?



  • g++ command that fails:

    g++ -m32 -Wl,-O1 -fuse-ld=gold -Wl,--enable-new-dtags -o pdfviewer .obj/main.o .obj/mainwindow.o .obj/pageselector.o .obj/zoomselector.o .obj/pdfviewer_plugin_import.o .obj/qrc_resources.o .obj/moc_mainwindow.o .obj/moc_pageselector.o .obj/moc_zoomselector.o   -L/opt/Qt5-static/plugins/platforms -lqxcb -L/opt/Qt5-static/lib -L/lib -L/opt/Qt5-static/plugins/xcbglintegrations -lqxcb-glx-integration -lQt5XcbQpa -lQt5ServiceSupport -lQt5ThemeSupport -lQt5EventDispatcherSupport -lQt5FontDatabaseSupport -lfreetype -lfontconfig -lQt5GlxSupport -lXext -lQt5EdidSupport -lxcb-glx -lX11-xcb -lX11 -lXrender -lxcb-static -lxcb -L/opt/Qt5-static/plugins/imageformats -lqgif -lqicns -lqico -lqjpeg -lqmng -lmng -lqtga -lqtiff -lqwbmp -lqwebp -L/opt/Qt5-static/plugins/bearer -lqconnmanbearer -lqgenericbearer -lqnmbearer -lQt5DBus -ldbus-1 -L/home/diaprom/Downloads/qtpdf/lib -lQt5PdfWidgets -lQt5Pdf -lqtpdfium -lQt5Network -lQt5Widgets -lQt5Gui -lqtlibpng -lqtharfbuzz -lQt5Core -lm -lqtpcre2 -ldl -lgthread-2.0 -lglib-2.0 -lrt -lGL -lpthread
    

    with '-v' flag I get this command:

    /opt/rh/devtoolset-3/root/usr/libexec/gcc/i686-redhat-linux/4.9.2/collect2 -plugin /opt/rh/devtoolset-3/root/usr/libexec/gcc/i686-redhat-linux/4.9.2/liblto_plugin.so -plugin-opt=/opt/rh/devtoolset-3/root/usr/libexec/gcc/i686-redhat-linux/4.9.2/lto-wrapper -plugin-opt=-fresolution=/tmp/ccaTRrx2.res -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc --build-id --no-add-needed --eh-frame-hdr --hash-style=gnu -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 -fuse-ld=gold -o pdfviewer /usr/lib/crt1.o /usr/lib/crti.o /opt/rh/devtoolset-3/root/usr/lib/gcc/i686-redhat-linux/4.9.2/crtbegin.o -L/opt/Qt5-static/plugins/platforms -L/opt/Qt5-static/lib -L/lib -L/opt/Qt5-static/plugins/xcbglintegrations -L/opt/Qt5-static/plugins/imageformats -L/opt/Qt5-static/plugins/bearer -L/home/diaprom/Downloads/qtpdf/lib -L/opt/rh/devtoolset-3/root/usr/lib/gcc/i686-redhat-linux/4.9.2 -L/opt/rh/devtoolset-3/root/usr/lib/gcc/i686-redhat-linux/4.9.2/../../.. -O1 --enable-new-dtags .obj/main.o .obj/mainwindow.o .obj/pageselector.o .obj/zoomselector.o .obj/pdfviewer_plugin_import.o .obj/qrc_resources.o .obj/moc_mainwindow.o .obj/moc_pageselector.o .obj/moc_zoomselector.o -lqxcb -lqxcb-glx-integration -lQt5XcbQpa -lQt5ServiceSupport -lQt5ThemeSupport -lQt5EventDispatcherSupport -lQt5FontDatabaseSupport -lfreetype -lfontconfig -lQt5GlxSupport -lXext -lQt5EdidSupport -lxcb-glx -lX11-xcb -lX11 -lXrender -lxcb-static -lxcb -lqgif -lqicns -lqico -lqjpeg -lqmng -lmng -lqtga -lqtiff -lqwbmp -lqwebp -lqconnmanbearer -lqgenericbearer -lqnmbearer -lQt5DBus -ldbus-1 -lQt5PdfWidgets -lQt5Pdf -lqtpdfium -lQt5Network -lQt5Widgets -lQt5Gui -lqtlibpng -lqtharfbuzz -lQt5Core -lqtpcre2 -ldl -lgthread-2.0 -lglib-2.0 -lrt -lGL -lpthread -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /opt/rh/devtoolset-3/root/usr/lib/gcc/i686-redhat-linux/4.9.2/crtend.o /usr/lib/crtn.o
    


    1. Are you sure that -L/home/diaprom/Downloads/qtpdf/lib is where the archive is really located?
    2. How old is the PDF library? probably not an issue with modern version archives but in the old days ABI changes could cause symbol names to change depending upon what version compiler created them.
    3. just for grins enter the failed compiler line by hand, but add the libqtpdfium.a like you would a common object file. IIRC, .a files can be listed like any other object on the compiler line.


  • @Kent-Dorfman said in Can't build QtPdf example with static Qt:

    1. Are you sure that -L/home/diaprom/Downloads/qtpdf/lib is where the archive is really located?
    2. How old is the PDF library? probably not an issue with modern version archives but in the old days ABI changes could cause symbol names to change depending upon what version compiler created them.
    3. just for grins enter the failed compiler line by hand, but add the libqtpdfium.a like you would a common object file. IIRC, .a files can be listed like any other object on the compiler line.
    1. Yes
    ls /home/diaprom/Downloads/qtpdf/lib
    cmake  libQt5Pdf.a  libQt5Pdf.la  libQt5Pdf.prl  libQt5PdfWidgets.a  libQt5PdfWidgets.la  libQt5PdfWidgets.prl  libqtpdfium.a  libqtpdfium.prl  pkgconfig
    
    1. git takes last version from source (git submodule update --init --recursive)
    2. Same output


  • It looks like your pdf difectory is a separately built library directory. What's in pkgconfig and are you using it, or are you manually including headers and link objects in your .pro file?


Log in to reply