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

How do i use poppler lib in Qt quick application.



  • sir,
    how do i use plopper library in Qt quick application (using qmake). could you give me instructions to use poppler with my application.





  • @eyllanesc
    sir ,
    when i tried to build for android it shows error: cannot find -lpoppler-qt5

    Screenshot from 2021-03-27 21-16-42.png


  • Lifetime Qt Champion

    @NIvil-Wilson said in How do i use poppler lib in Qt quick application.:

    cannot find -lpoppler-qt5

    Did you build poppler for Android?
    From your screen-shot it does not look like you did...



  • @jsulm
    sir,
    i dont know how to build poppler for android.could you please tell me.


  • Lifetime Qt Champion



  • @jsulm
    after building poppler for android it shows the same errror
    skipping incompatible /usr/local/lib//libpoppler-qt5.so when searching for -lpoppler-qt5.


  • Lifetime Qt Champion

    @NIvil-Wilson said in How do i use poppler lib in Qt quick application.:

    /usr/local/lib//libpoppler-qt5.so

    I'm sure this is not poppler built for Android.
    You have to provide proper path to the Android version using LIBS.



  • @jsulm
    sir,
    this is my cmak_install file.could you please check it .

    # Install script for directory: /home/nivilwilsonp/Pictures/poppler-21.03.0
    
    # Set the install prefix
    if(NOT DEFINED CMAKE_INSTALL_PREFIX)
      set(CMAKE_INSTALL_PREFIX "/usr/local")
    endif()
    string(REGEX REPLACE "/$" "" CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
    
    # Set the install configuration name.
    if(NOT DEFINED CMAKE_INSTALL_CONFIG_NAME)
      if(BUILD_TYPE)
        string(REGEX REPLACE "^[^A-Za-z0-9_]+" ""
               CMAKE_INSTALL_CONFIG_NAME "${BUILD_TYPE}")
      else()
        set(CMAKE_INSTALL_CONFIG_NAME "RelWithDebInfo")
      endif()
      message(STATUS "Install configuration: \"${CMAKE_INSTALL_CONFIG_NAME}\"")
    endif()
    
    # Set the component getting installed.
    if(NOT CMAKE_INSTALL_COMPONENT)
      if(COMPONENT)
        message(STATUS "Install component: \"${COMPONENT}\"")
        set(CMAKE_INSTALL_COMPONENT "${COMPONENT}")
      else()
        set(CMAKE_INSTALL_COMPONENT)
      endif()
    endif()
    
    # Install shared libraries without execute permission?
    if(NOT DEFINED CMAKE_INSTALL_SO_NO_EXE)
      set(CMAKE_INSTALL_SO_NO_EXE "1")
    endif()
    
    # Is this installation the result of a crosscompile?
    if(NOT DEFINED CMAKE_CROSSCOMPILING)
      set(CMAKE_CROSSCOMPILING "TRUE")
      set(CMAKE_SYSTEM_NAME Android)
    set(CMAKE_SYSTEM_VERSION 24) # API level
    set(CMAKE_ANDROID_ARCH_ABI armeabi-v7a)
    set(CMAKE_ANDROID_NDK /home/nivilwilsonp/Android/Sdk/ndk/21.3.6528147)
    set(CMAKE_ANDROID_STL_TYPE gnustl_static)
    endif()
    
    if("x${CMAKE_INSTALL_COMPONENT}x" STREQUAL "xUnspecifiedx" OR NOT CMAKE_INSTALL_COMPONENT)
      foreach(file
          "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/lib/libpoppler.so.108.0.0"
          "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/lib/libpoppler.so.108"
          )
        if(EXISTS "${file}" AND
           NOT IS_SYMLINK "${file}")
          file(RPATH_CHECK
               FILE "${file}"
               RPATH "")
        endif()
      endforeach()
      file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/lib" TYPE SHARED_LIBRARY FILES
        "/home/nivilwilsonp/Pictures/poppler-21.03.0/build/libpoppler.so.108.0.0"
        "/home/nivilwilsonp/Pictures/poppler-21.03.0/build/libpoppler.so.108"
        )
      foreach(file
          "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/lib/libpoppler.so.108.0.0"
          "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/lib/libpoppler.so.108"
          )
        if(EXISTS "${file}" AND
           NOT IS_SYMLINK "${file}")
          if(CMAKE_INSTALL_DO_STRIP)
            execute_process(COMMAND "/usr/bin/strip" "${file}")
          endif()
        endif()
      endforeach()
    endif()
    
    if("x${CMAKE_INSTALL_COMPONENT}x" STREQUAL "xUnspecifiedx" OR NOT CMAKE_INSTALL_COMPONENT)
      if(EXISTS "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/lib/libpoppler.so" AND
         NOT IS_SYMLINK "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/lib/libpoppler.so")
        file(RPATH_CHECK
             FILE "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/lib/libpoppler.so"
             RPATH "")
      endif()
      file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/lib" TYPE SHARED_LIBRARY FILES "/home/nivilwilsonp/Pictures/poppler-21.03.0/build/libpoppler.so")
      if(EXISTS "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/lib/libpoppler.so" AND
         NOT IS_SYMLINK "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/lib/libpoppler.so")
        if(CMAKE_INSTALL_DO_STRIP)
          execute_process(COMMAND "/usr/bin/strip" "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/lib/libpoppler.so")
        endif()
      endif()
    endif()
    
    if("x${CMAKE_INSTALL_COMPONENT}x" STREQUAL "xUnspecifiedx" OR NOT CMAKE_INSTALL_COMPONENT)
      file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/pkgconfig" TYPE FILE FILES "/home/nivilwilsonp/Pictures/poppler-21.03.0/build/poppler.pc")
    endif()
    
    if("x${CMAKE_INSTALL_COMPONENT}x" STREQUAL "xUnspecifiedx" OR NOT CMAKE_INSTALL_COMPONENT)
      file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/pkgconfig" TYPE FILE FILES "/home/nivilwilsonp/Pictures/poppler-21.03.0/build/poppler-qt5.pc")
    endif()
    
    if("x${CMAKE_INSTALL_COMPONENT}x" STREQUAL "xUnspecifiedx" OR NOT CMAKE_INSTALL_COMPONENT)
      file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/pkgconfig" TYPE FILE FILES "/home/nivilwilsonp/Pictures/poppler-21.03.0/build/poppler-cpp.pc")
    endif()
    
    if(NOT CMAKE_INSTALL_LOCAL_ONLY)
      # Include the install script for each subdirectory.
      include("/home/nivilwilsonp/Pictures/poppler-21.03.0/build/utils/cmake_install.cmake")
      include("/home/nivilwilsonp/Pictures/poppler-21.03.0/build/test/cmake_install.cmake")
      include("/home/nivilwilsonp/Pictures/poppler-21.03.0/build/qt5/cmake_install.cmake")
      include("/home/nivilwilsonp/Pictures/poppler-21.03.0/build/cpp/cmake_install.cmake")
    
    endif()
    
    if(CMAKE_INSTALL_COMPONENT)
      set(CMAKE_INSTALL_MANIFEST "install_manifest_${CMAKE_INSTALL_COMPONENT}.txt")
    else()
      set(CMAKE_INSTALL_MANIFEST "install_manifest.txt")
    endif()
    
    string(REPLACE ";" "\n" CMAKE_INSTALL_MANIFEST_CONTENT
           "${CMAKE_INSTALL_MANIFEST_FILES}")
    file(WRITE "/home/nivilwilsonp/Pictures/poppler-21.03.0/build/${CMAKE_INSTALL_MANIFEST}"
         "${CMAKE_INSTALL_MANIFEST_CONTENT}")
    

  • Lifetime Qt Champion

    Hi,

    I would avoid putting a library like that built for a different architecture/OS in such a generic path. You should store in an explicit dedicated folder.


  • Lifetime Qt Champion

    @NIvil-Wilson said in How do i use poppler lib in Qt quick application.:

    skipping incompatible /usr/local/lib//libpoppler-qt5.so when searching for -lpoppler-qt5.

    This error clearly states that /usr/local/lib//libpoppler-qt5.so is not compatible with what you are building.
    Do

    file /usr/local/lib//libpoppler-qt5.so
    

    and post its output here.



  • @jsulm said in How do i use poppler lib in Qt quick application.:

    file /usr/local/lib//libpoppler-qt5.so

    /usr/local/lib//libpoppler-qt5.so: symbolic link to libpoppler-qt5.so.1


  • Lifetime Qt Champion

    @NIvil-Wilson Then do

    file /usr/local/lib//libpoppler-qt5.so.1
    


  • @jsulm
    sir,
    the result for the command file /usr/local/lib//libpoppler-qt5.so.1 is
    /usr/local/lib//libpoppler-qt5.so.1: symbolic link to libpoppler-qt5.so.1.27.0



  • @SGaist
    sir, i tried that too but the same problem occurs


  • Lifetime Qt Champion

    @NIvil-Wilson said in How do i use poppler lib in Qt quick application.:

    @jsulm
    sir,
    the result for the command file /usr/local/lib//libpoppler-qt5.so.1 is
    /usr/local/lib//libpoppler-qt5.so.1: symbolic link to libpoppler-qt5.so.1.27.0

    Check that file then.

    Did you ensure that cmake is finding your cross-compiled version and not the one from your system ?



  • @SGaist
    sir,
    yes i ensured that the cmake is finding cross-compiled version and not the one from the system .
    i stored the cross-compiled version in an explicit dedicated folder and the same message appears.
    please help


  • Lifetime Qt Champion

    Did you check the architecture of your cross-compiled library ?



  • @SGaist
    sir ,
    the architecture of cross-compiled library is given below.

    readelf -h libpoppler-qt5.so.1.27.0
    ELF Header:
    Magic: 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
    Class: ELF64
    Data: 2's complement, little endian
    Version: 1 (current)
    OS/ABI: UNIX - System V
    ABI Version: 0
    Type: DYN (Shared object file)
    Machine: Advanced Micro Devices X86-64
    Version: 0x1
    Entry point address: 0x334f0
    Start of program headers: 64 (bytes into file)
    Start of section headers: 14323992 (bytes into file)
    Flags: 0x0
    Size of this header: 64 (bytes)
    Size of program headers: 56 (bytes)
    Number of program headers: 11
    Size of section headers: 64 (bytes)
    Number of section headers: 39
    Section header string table index: 38


  • Lifetime Qt Champion

    @NIvil-Wilson said in How do i use poppler lib in Qt quick application.:

    Machine: Advanced Micro Devices X86-64

    Is your device running on a x86_64 machine ?



  • @SGaist said in How do i use poppler lib in Qt quick application.:

    x86_64

    uname -a
    Linux nivilwilsonp-desktop 5.8.0-48-generic #54~20.04.1-Ubuntu SMP Sat Mar 20 13:40:25 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux


  • Lifetime Qt Champion

    Your desktop machine is.

    I meant the target that runs Android. In any case, if it's ARM, libpoppler was not cross-compiled.



  • @SGaist
    sir,
    the target device is ARM.could you give me instructions to cross compile libpoppler for ARM.


  • Lifetime Qt Champion

    What did you do to build poppler until now ?



  • @SGaist
    sir,
    i used the settings given below to cross compile poppler library

    if(NOT DEFINED CMAKE_CROSSCOMPILING)
    set(CMAKE_CROSSCOMPILING "TRUE")
    endif()

    set(CMAKE_SYSTEM_NAME Android)
    set(CMAKE_SYSTEM_VERSION 21) # API level
    set(CMAKE_ANDROID_ARCH_ABI arm64-v8a)
    set(CMAKE_ANDROID_NDK /home/nivilwilsonp/Android/Sdk/ndk/21.3.6528147)
    set(CMAKE_ANDROID_STL_TYPE c++_shared)


  • Lifetime Qt Champion

    You might want to check here for how they build it for Androïd.



  • @SGaist
    sir, i tried to compile poppler for android arm64-v8a but it always compiled to "x86_64".


  • Lifetime Qt Champion

    Did you follow the example I linked ?



  • @SGaist
    sir, i tried it many times .i changed the architecture and tried many times but it only compile to x86_64 architecture only.I think this is related to configuration mistake that i made cmake compilation process. sorry for my bad english .google translate help me very much these days.


  • Lifetime Qt Champion

    What did you do exactly for your latest try ?



  • @SGaist
    sir, i couldnt understant this line " CFLAGS=-std=gnu99 STANDALONE_EXTRA="--arch arm64" /opt/helpers/build-standalone " which is in the link you given click here

    Screenshot from 2021-06-11 18-01-59.png


  • Lifetime Qt Champion

    The line contains the instructions to configure, build and install freetype for Android..



  • @SGaist
    sir,

    Screenshot from 2021-06-12 14-10-50.png

    cmake -G Ninja .. -DCMAKE_TOOLCHAIN_FILE=~/Desktop/c++/poppler-21.06.1/build.cmake

    contents of CMakeError.log

    Determining if the function fseek64 exists failed with the following output:
    Change Dir: /home/nivilwilsonp/Desktop/c++/poppler-21.06.1/build/CMakeFiles/CMakeTmp

    Run Build Command(s):/usr/bin/ninja cmTC_8bd25 && [1/2] Building C object CMakeFiles/cmTC_8bd25.dir/CheckFunctionExists.c.o
    [2/2] Linking C executable cmTC_8bd25
    FAILED: cmTC_8bd25
    : && /home/nivilwilsonp/Android/Sdk/ndk/21.3.6528147/toolchains/llvm/prebuilt/linux-x86_64/bin/clang --target=aarch64-none-linux-android21 -Wall -std=c99 -D_DEFAULT_SOURCE -DCHECK_FUNCTION_EXISTS=fseek64 -g -funwind-tables -no-canonical-prefixes -fexceptions -fPIE -pie -Wl,--gc-sections CMakeFiles/cmTC_8bd25.dir/CheckFunctionExists.c.o -o cmTC_8bd25 -latomic -lm && :
    CMakeFiles/cmTC_8bd25.dir/CheckFunctionExists.c.o: In function main': /usr/share/cmake-3.16/Modules/CheckFunctionExists.c:17: undefined reference tofseek64'
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    ninja: build stopped: subcommand failed.

    Determining if the function ftell64 exists failed with the following output:
    Change Dir: /home/nivilwilsonp/Desktop/c++/poppler-21.06.1/build/CMakeFiles/CMakeTmp

    Run Build Command(s):/usr/bin/ninja cmTC_5f037 && [1/2] Building C object CMakeFiles/cmTC_5f037.dir/CheckFunctionExists.c.o
    [2/2] Linking C executable cmTC_5f037
    FAILED: cmTC_5f037
    : && /home/nivilwilsonp/Android/Sdk/ndk/21.3.6528147/toolchains/llvm/prebuilt/linux-x86_64/bin/clang --target=aarch64-none-linux-android21 -Wall -std=c99 -D_DEFAULT_SOURCE -DCHECK_FUNCTION_EXISTS=ftell64 -g -funwind-tables -no-canonical-prefixes -fexceptions -fPIE -pie -Wl,--gc-sections CMakeFiles/cmTC_5f037.dir/CheckFunctionExists.c.o -o cmTC_5f037 -latomic -lm && :
    CMakeFiles/cmTC_5f037.dir/CheckFunctionExists.c.o: In function main': /usr/share/cmake-3.16/Modules/CheckFunctionExists.c:17: undefined reference toftell64'
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    ninja: build stopped: subcommand failed.

    Performing C SOURCE FILE Test HAVE_NDIR_H failed with the following output:
    Change Dir: /home/nivilwilsonp/Desktop/c++/poppler-21.06.1/build/CMakeFiles/CMakeTmp

    Run Build Command(s):/usr/bin/ninja cmTC_53db5 && [1/2] Building C object CMakeFiles/cmTC_53db5.dir/src.c.o
    FAILED: CMakeFiles/cmTC_53db5.dir/src.c.o
    /home/nivilwilsonp/Android/Sdk/ndk/21.3.6528147/toolchains/llvm/prebuilt/linux-x86_64/bin/clang --target=aarch64-none-linux-android21 -Wall -std=c99 -D_DEFAULT_SOURCE -DHAVE_NDIR_H -g -funwind-tables -no-canonical-prefixes -fexceptions -o CMakeFiles/cmTC_53db5.dir/src.c.o -c src.c
    src.c:1:10: fatal error: 'ndir.h' file not found
    #include <ndir.h>
    ^~~~~~~~
    1 error generated.
    ninja: build stopped: subcommand failed.

    Source file was:
    #include <ndir.h>

    int main(int argc, char argv[])
    {
    DIR
    d = 0;
    return 0;
    }

    Performing C SOURCE FILE Test HAVE_SYS_DIR_H failed with the following output:
    Change Dir: /home/nivilwilsonp/Desktop/c++/poppler-21.06.1/build/CMakeFiles/CMakeTmp

    Run Build Command(s):/usr/bin/ninja cmTC_4a64d && [1/2] Building C object CMakeFiles/cmTC_4a64d.dir/src.c.o
    FAILED: CMakeFiles/cmTC_4a64d.dir/src.c.o
    /home/nivilwilsonp/Android/Sdk/ndk/21.3.6528147/toolchains/llvm/prebuilt/linux-x86_64/bin/clang --target=aarch64-none-linux-android21 -Wall -std=c99 -D_DEFAULT_SOURCE -DHAVE_SYS_DIR_H -g -funwind-tables -no-canonical-prefixes -fexceptions -o CMakeFiles/cmTC_4a64d.dir/src.c.o -c src.c
    src.c:1:10: fatal error: 'sys/dir.h' file not found
    #include <sys/dir.h>
    ^~~~~~~~~~~
    1 error generated.
    ninja: build stopped: subcommand failed.

    Source file was:
    #include <sys/dir.h>

    int main(int argc, char argv[])
    {
    DIR
    d = 0;
    return 0;
    }

    Performing C SOURCE FILE Test HAVE_SYS_NDIR_H failed with the following output:
    Change Dir: /home/nivilwilsonp/Desktop/c++/poppler-21.06.1/build/CMakeFiles/CMakeTmp

    Run Build Command(s):/usr/bin/ninja cmTC_5a9f7 && [1/2] Building C object CMakeFiles/cmTC_5a9f7.dir/src.c.o
    FAILED: CMakeFiles/cmTC_5a9f7.dir/src.c.o
    /home/nivilwilsonp/Android/Sdk/ndk/21.3.6528147/toolchains/llvm/prebuilt/linux-x86_64/bin/clang --target=aarch64-none-linux-android21 -Wall -std=c99 -D_DEFAULT_SOURCE -DHAVE_SYS_NDIR_H -g -funwind-tables -no-canonical-prefixes -fexceptions -o CMakeFiles/cmTC_5a9f7.dir/src.c.o -c src.c
    src.c:1:10: fatal error: 'sys/ndir.h' file not found
    #include <sys/ndir.h>
    ^~~~~~~~~~~~
    1 error generated.
    ninja: build stopped: subcommand failed.

    Source file was:
    #include <sys/ndir.h>

    int main(int argc, char argv[])
    {
    DIR
    d = 0;
    return 0;
    }


  • Lifetime Qt Champion

    Which step did you do exactly ?


Log in to reply