The conflict between quazip and mupdf-qt



  • Hi.

    In my project, I use quazip to work with the archive. Now it was necessary to draw a PDF document. For this, I decided to use mupdf-qt, but if they are used simultaneously, an error occurs. I absolutely do not understand what this is connected with.
    Maybe you can tell me what the problem is?

    QuaZIP
    https://github.com/mnafees/quazip

    mupdf-qt
    https://github.com/xiangxw/mupdf-qt

    Ubuntu 14.04, 64bit
    Qt 5.7.1

    .pro

    ...
    
    DEFINES += QUAZIP_STATIC
    
    unix {
        # quazip
        QUAZIPCODEDIR = "/home/alexorleon/QtProjects/libs/quazip-0.7.2/quazip"
        ZLIBCODEDIR = "/home/alexorleon/QtProjects/libs/Libs"
        INCLUDEPATH += $${QUAZIPCODEDIR}
        LIBS += -L$${ZLIBCODEDIR} -lz
    
        # mupdf-qt
        INCLUDEPATH += "/home/alexorleon/Development/Projects/mupdf-qt/include"
        LIBS += -L/home/alexorleon/Development/Projects/mupdf-qt/build/lib -lmupdf-qt
        LIBS += -L/home/alexorleon/Development/Projects/mupdf-qt/mupdf/build/debug/ -lmupdf  -ljpeg -lfreetype -lz -ljbig2dec -lcrypto -ldl -lmujs -lopenjpeg
    }
    
    SOURCES += main.cpp \
        $${QUAZIPCODEDIR}/*.cpp \
        $${QUAZIPCODEDIR}/*.c
    
    HEADERS += $${QUAZIPCODEDIR}/*.h
    ...
    
    

    main.cpp

    #include <QGuiApplication>
    #include <QQmlApplicationEngine>
    #include <QImage>
    #include <QDebug>
    
    #include "JlCompress.h"
    #include "mupdf-qt.h"
    
    int main(int argc, char *argv[])
    {
        QGuiApplication app(argc, argv);
    
    
        QQmlApplicationEngine engine;
        engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
    
        JlCompress::extractDir("/home/alexorleon/Deployment/doc.zip", "/home/alexorleon/Deployment/temp");
    
        QString filename("/home/alexorleon/doc.pdf");
        MuPDF::Document *document = MuPDF::loadDocument(filename);
        if (document) {
    
            // number of pages
            qDebug() << "pages: " << document->numPages();
            // other informations
            qDebug() << "version: " << document->pdfVersion();
            qDebug() << "title: " << document->title();
            qDebug() << "author: " << document->author();
            qDebug() << "subject: " << document->subject();
            qDebug() << "keywords: " << document->keywords();
            qDebug() << "creator: " << document->creator();
            qDebug() << "producer: " << document->producer();
            //qDebug() << "creation date: " << document->creationDate();
            //qDebug() << "recently modify date: " << document->modDate();
    
            MuPDF::Page *page = document->page(1);
            if (page) {
                float scaleX = 1.0f;
                float scaleY = 1.0f;
                float rotation = 0.0f;
                QImage image = page->renderImage(scaleX, scaleY, rotation);
                // do something with the QImage
                image.save("/home/alexorleon/test.jpeg", "JPEG");
                // do not forget this
                delete page;
            }
    
            // do not forget to delete it
            delete document;
        }
    
        return app.exec();
    }
    

    error: quagzipfile.o: undefined character reference «gzdopen»
    /lib/x86_64-linux-gnu/libz.so.1:-1: error: error adding symbols: DSO missing from command line
    error: collect2: error: ld returned 1 exit status

    But if I comment out one of the libraries, then everything works.
    For example:

    # quazip
    #QUAZIPCODEDIR = "/home/alexorleon/QtProjects/libs/quazip-0.7.2/quazip"
    #ZLIBCODEDIR = "/home/alexorleon/QtProjects/libs/Libs"
    #INCLUDEPATH += $${QUAZIPCODEDIR}
    #LIBS += -L$${ZLIBCODEDIR} -lz
    
    //#include "JlCompress.h"
    
    //JlCompress::extractDir("/home/alexorleon/Deployment/doc.zip", "/home/alexorleon/Deployment/temp");
    

  • Lifetime Qt Champion

    Hi,

    Did you build these two libraries yourself ?
    Which version of gcc are you using ?



  • @Alexorleon said in The conflict between quazip and mupdf-qt:

    error: quagzipfile.o: undefined character reference «gzdopen»
    /lib/x86_64-linux-gnu/libz.so.1:-1: error: error adding symbols: DSO missing from command line

    This error comes from linking order. You are linking your objects that use the library after the library itself. Change your link order and it should work.

    Your problem should be in these lines:

        LIBS += -L/home/alexorleon/Development/Projects/mupdf-qt/build/lib -lmupdf-qt
        LIBS += -L/home/alexorleon/Development/Projects/mupdf-qt/mupdf/build/debug/ -lmupdf  -ljpeg -lfreetype -lz -ljbig2dec -lcrypto -ldl -lmujs -lopenjpeg
    

    My guess is move that -lz further down the line... try at the end maybe.


  • Qt Champions 2016

    SOURCES += main.cpp \
        $${QUAZIPCODEDIR}/*.cpp \
        $${QUAZIPCODEDIR}/*.c
    
    HEADERS += $${QUAZIPCODEDIR}/*.h
    

    ??!

    Why do you add the source directly in your build tree?



  • @kshegunov said in The conflict between quazip and mupdf-qt:

    SOURCES += main.cpp \
        $${QUAZIPCODEDIR}/*.cpp \
        $${QUAZIPCODEDIR}/*.c
    
    HEADERS += $${QUAZIPCODEDIR}/*.h
    

    ??!

    Why do you add the source directly in your build tree?

    I didn't even notice that. I wasn't looking thoroughly though since I knew what was the likely culprit based on the error. That is definitely a contributing factor to the error though.

    He definitely needs to remove that from his qmake. Good catch!



  • @SGaist Yes, both libraries I compiled by myself. gcc version 4.8.4



  • @ambershark Yes, I tried to do so. It did not help.

    @kshegunov This is necessary to use .c files. Maybe, I do not remember ;) Maybe I should try to add only specific files.



  • From time to time I try different solutions, but for now I decided to use poppler. Everything is working.



  • If I comment the lines

    SOURCES += main.cpp# \
        #$${QUAZIPCODEDIR}/*.cpp \
        #$${QUAZIPCODEDIR}/*.c
    
    #HEADERS += $${QUAZIPCODEDIR}/*.h
    

    error: undefined reference to `JlCompress::extractDir(QString, QString)'


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.