Solved 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
http://blog.qt.io/blog/2017/01/30/new-qtpdf-qtlabs-module/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++-7Now 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_armv7In 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-installermake
...
/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 to
main'
.obj/fpdfview.o: In functionFPDF_InitLibraryWithConfig': /home/alexorleon/Development/Projects/pdf/android/qtpdf/src/lib/../3rdparty/pdfium/fpdfsdk/fpdfview.cpp:282: undefined reference to
IJS_Runtime::Initialize(unsigned int, void*)'
.obj/fpdfview.o: In functionFPDF_DestroyLibrary': /home/alexorleon/Development/Projects/pdf/android/qtpdf/src/lib/../3rdparty/pdfium/fpdfsdk/fpdfview.cpp:295: undefined reference to
IJS_Runtime::Destroy()'
.obj/fsdk_mgr.o: In functionCPDFDoc_Environment::GetJSRuntime()': /home/alexorleon/Development/Projects/pdf/android/qtpdf/src/lib/../3rdparty/pdfium/fpdfsdk/fsdk_mgr.cpp:216: undefined reference to
IJS_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] Ошибка 2IJS_Runtime. What is it?
I can not find the cause of this error. Any ideas? Maybe I need to use VS on Windows? -
Hi,
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
-
@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 "libQt5Pdf.so" not foundIn 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
│ ├── libOr need to specify
├── android-build
│ │ └── home
│ │ └── alexorleon
│ │ └── Qt
│ │ └── 5.9.3
│ │ └── android_armv7
│ │ ├── include
│ │ │ └── QtPdf
│ │ ├── libI tried different options.
-
You have to first compile QtPdf for Android using your Qt for Android installation.
-
@SGaist I did this and specify this file.
build-qpdf-Android_armeabi_v7a_GCC_4_9_Qt_Qt_5_9_3_armv7-Release
-
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.