Important: Please read the Qt Code of Conduct -

QtPdf Android

  • Hi,
    i am trying to create a pdf viewer inside Qt. Before I used the poppler. But now there is a need to do this under android.

    I decided to try QtPdf

    Ubuntu 14.04 x64, Qt 5.9.3, gcc 4.8.4

    First under desktop. Install gcc 7.2. If this is not done there will be an error unrecognized command line option ‘-std=c++1z’
    Add to PATH Qt 5.9.3 gcc.

    sudo add-apt-repository ppa:ubuntu-toolchain-r/test
    sudo apt update
    sudo apt install gcc-7
    sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 60 --slave /usr/bin/g++ g++ /usr/bin/g++-7

    Now make works steadily. Example pdfviewer can be run through Qt Creator. Everything is going, pdf is opening. I added the code from the example to myself, the image of the page is created.

    Now under android 7.0. API level 24
    Add to PATH Qt android_armv7

    In Qt Creator I use jdk1.8.0_161.
    sudo add-apt-repository ppa:webupd8team/java
    sudo apt-get update
    sudo apt-get install oracle-java8-installer

    /usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_line): перемещение 0 имеет недопустимый индекс символа 2
    /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/crt1.o: In function _start': (.text+0x20): undefined reference tomain'
    .obj/fpdfview.o: In function FPDF_InitLibraryWithConfig': /home/alexorleon/Development/Projects/pdf/android/qtpdf/src/lib/../3rdparty/pdfium/fpdfsdk/fpdfview.cpp:282: undefined reference toIJS_Runtime::Initialize(unsigned int, void*)'
    .obj/fpdfview.o: In function FPDF_DestroyLibrary': /home/alexorleon/Development/Projects/pdf/android/qtpdf/src/lib/../3rdparty/pdfium/fpdfsdk/fpdfview.cpp:295: undefined reference toIJS_Runtime::Destroy()'
    .obj/fsdk_mgr.o: In function CPDFDoc_Environment::GetJSRuntime()': /home/alexorleon/Development/Projects/pdf/android/qtpdf/src/lib/../3rdparty/pdfium/fpdfsdk/fsdk_mgr.cpp:216: undefined reference toIJS_Runtime::Create(CPDFDoc_Environment*)'
    collect2: error: ld returned 1 exit status
    make[2]: *** [qtpdfium] Ошибка 1
    make[2]: Выход из каталога /home/alexorleon/Development/Projects/pdf/android/qtpdf/src/lib' make[1]: *** [sub-lib-make_first-ordered] Ошибка 2 make[1]: Выход из каталога/home/alexorleon/Development/Projects/pdf/android/qtpdf/src'
    make: *** [sub-src-make_first] Ошибка 2

    IJS_Runtime. What is it?
    I can not find the cause of this error. Any ideas? Maybe I need to use VS on Windows?

  • Lifetime Qt Champion


    Something's not clear: did you install Qt for Android development ?

    Also, how did you install Qt ?
    Furthermore, the error lines that you show looks like you are building using your desktop compiler which means that you are currently not building for Android at all.

  • @SGaist, I used online installer. Qt 5.9.3 android_armv7

  • Lifetime Qt Champion

    @Alexorleon Did you select the proper (Android) Kit in QtCreator? As @SGaist pointed out you're not building for Android.

  • I used the command line. But after your words I decided to try it in Qt Creator.
    It seems the library has successfully assembled.

    But when i start, the program crashes on the device:
    E AndroidRuntime: java.lang.UnsatisfiedLinkError: dlopen failed: library "" not found

    In the application, I use other libraries, without QtPdf everything works.

    I use the correct directory?

    INCLUDEPATH += "/home/alexorleon/Development/Projects/pdf/android/build-qpdf-Android_armeabi_v7a_GCC_4_9_Qt_Qt_5_9_3_armv7-Release/include/QtPdf"
    LIBS += -L/home/alexorleon/Development/Projects/pdf/android/build-qpdf-Android_armeabi_v7a_GCC_4_9_Qt_Qt_5_9_3_armv7-Release/lib -lQt5Pdf

    ├── build-qpdf-Android_armeabi_v7a_GCC_4_9_Qt_Qt_5_9_3_armv7-Release
    │ ├── android-build
    │ │ └── home
    │ │ └── alexorleon
    │ │ └── Qt
    │ │ └── 5.9.3
    │ │ └── android_armv7
    │ │ ├── include
    │ │ │ └── QtPdf
    │ │ ├── lib
    │ ├── bin
    │ ├── include
    │ │ └── QtPdf
    │ ├── lib
    │ │ ├── cmake
    │ │ │ └── Qt5Pdf
    │ │ └── pkgconfig
    ├── qtpdf
    │ ├── include
    │ │ └── QtPdf
    │ ├── lib

    Or need to specify
    ├── android-build
    │ │ └── home
    │ │ └── alexorleon
    │ │ └── Qt
    │ │ └── 5.9.3
    │ │ └── android_armv7
    │ │ ├── include
    │ │ │ └── QtPdf
    │ │ ├── lib

    I tried different options.

  • Lifetime Qt Champion

    You have to first compile QtPdf for Android using your Qt for Android installation.

  • @SGaist I did this and specify this file.


  • Lifetime Qt Champion

    My bad, I misread your last post.

    Did you bundle that library with your application also ?

    Look at the Project panel. (more information here)

  • @Alexorleon I guess you may need to copy the library from your build directory into the proper location in your project using it.
    Do you have already this folder structure in your project?

    <PROJECT ROOT> / android / libs / armeabi-v7a /

    While building your application for Android, Qt Creator expects some components in particular locations.

  • Thanks for the help!
    I created the AndroidManifest and added the ANDROID_EXTRA_LIBS line to the .pro file.

  • @Alexorleon please be aware that you can manage (edit) the manifest from within Qt Creator. And once your issue is solved, please don't forget to mark your post as such.

Log in to reply