[ANDROID] Make failed because of external library



  • Hello,

    I have done this little application which use poppler-qt5 for load PDF and after testing this app on Desktop, I would like to test my application on Android.

    After researching about my error, I can't find a solution about that, it's the first time that I try to use a Qt Application on Android with an external library.

    Here is my .pro file :

    TEMPLATE = app
    
    QT += qml quick
    QT += svg
    
    INCLUDEPATH += /usr/local/include/poppler/qt5
    LIBS += -L/usr/local/lib -lpoppler-qt5
    
    CONFIG += c++11 mobility
    
    SOURCES += main.cpp \
        pdfchooser.cpp
    
    RESOURCES += qml.qrc
    
    # Additional import path used to resolve QML modules in Qt Creator's code model
    QML_IMPORT_PATH =
    
    # Default rules for deployment.
    include(deployment.pri)
    
    HEADERS += \
        pdfchooser.h
    
    

    And this is what I get after make :

    /Users/me/Documents/Android/ndk-11/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9/../../../../arm-linux-androideabi/bin/ld: error: poppler-qt5: no archive symbol table (run ranlib)
    ../AndroidTest/pdfchooser.cpp:46: error: undefined reference to 'Poppler::Document::loadFromData(QByteArray const&, QByteArray const&, QByteArray const&)'
    ../AndroidTest/pdfchooser.cpp:49: error: undefined reference to 'Poppler::Document::isLocked() const'
    ../AndroidTest/pdfchooser.cpp:50: error: undefined reference to 'Poppler::Document::~Document()'
    ../AndroidTest/pdfchooser.cpp:54: error: undefined reference to 'Poppler::Document::setRenderBackend(Poppler::Document::RenderBackend)'
    ../AndroidTest/pdfchooser.cpp:55: error: undefined reference to 'Poppler::Document::setPaperColor(QColor const&)'
    ../AndroidTest/pdfchooser.cpp:60: error: undefined reference to 'Poppler::Document::page(int) const'
    ../AndroidTest/pdfchooser.cpp:60: error: undefined reference to 'Poppler::Page::pageSize() const'
    ../AndroidTest/pdfchooser.cpp:67: error: undefined reference to 'Poppler::Document::page(int) const'
    ../AndroidTest/pdfchooser.cpp:67: error: undefined reference to 'Poppler::Page::renderToPainter(QPainter*, double, double, int, int, int, int, Poppler::Page::Rotation, QFlags<Poppler::Page::PainterFlag>) const'
    ../AndroidTest/pdfchooser.cpp:73: error: undefined reference to 'Poppler::Document::~Document()'
    collect2: error: ld returned 1 exit status
    make: *** [libAndroidTest.so] Error 1
    10:29:01: Le processus "/usr/bin/make" s'est terminé avec le code 2.
    Erreur lors de la compilation/déploiement du projet AndroidTest (kit : Android for armeabi-v7a (GCC 4.9, Qt 5.5.1))
    When executing step "Make"
    

    It's a problem of my library because I have the same problem if I don't include the lib in the pro file and that I try to compile for desktop.

    I'll appreciate your help and your information which increase my knowledge of this language.

    Thanks



  • Hello. There may be a few different ways to 3rd party libraries to projects, but this how I recently added one with success.

    Following this guide: Third-party Android Libraries

    Basically, you

    1. Go to Projects > Build Steps > Create Templates
    2. Copy your lib to the 'android' folder within your project directory.
    3. Edit your 'project.properties' to include: android.library.reference.1=name_of_lib/
    4. Clean and rebuild for good measure.

    I did this with the Google Play Services lib and it worked as expected. I did not need to add anything additional to the .pro file, though my .pro does contain:

    ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android 
    

    I am using Qt 5.6. Hope this helps.



  • @Carmoneer Hum your answer is interesting but what do you mean by your first step when I must copy my lib ?

    Should I copy /lib & /include in the same directory ?

    Thanks for answer


Log in to reply
 

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