1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Cross-compiling issues with Qt4 fw

Discussion in 'Development' started by TimeWalker75a, 17 April 2017.

  1. TimeWalker75a

    TimeWalker75a New Member

    Messages:
    9
    Hardware:
    RPi3
    Trying to follow the cross-compiling routines and keep running into the following problem on both Ubuntu 16.04 and Mint 18.1 KDE. Qt installs as 4.8.7 from libqt4-dev.

    Code:
    CPack: Create package
    CPack: - package: /home/mint/hyperion/build-x86x64/hyperion-1.3.0-Linux-ambilight.sh generated.
    build directory = ./build-x86x64
    repository root dirrectory = .
    create ./deploy/hyperion_x86x64.tar.gz
    
    --- build release for rpi ---
    
    -- The C compiler identification is GNU 4.8.3
    -- The CXX compiler identification is GNU 4.8.3
    -- Check for working C compiler: /home/mint/raspberrypi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf-gcc
    -- Check for working C compiler: /home/mint/raspberrypi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf-gcc -- works
    -- Detecting C compiler ABI info
    -- Detecting C compiler ABI info - done
    -- Detecting C compile features
    -- Detecting C compile features - done
    -- Check for working CXX compiler: /home/mint/raspberrypi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf-g++
    -- Check for working CXX compiler: /home/mint/raspberrypi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf-g++ -- works
    -- Detecting CXX compiler ABI info
    -- Detecting CXX compiler ABI info - done
    -- Detecting CXX compile features
    -- Detecting CXX compile features - done
    -- ENABLE_ZEROCONF = OFF
    -- ENABLE_AMLOGIC = OFF
    -- ENABLE_DISPMANX = ON
    -- ENABLE_FB = OFF
    -- ENABLE_OSX = OFF
    -- ENABLE_SPIDEV   = ON
    -- ENABLE_TINKERFORGE = ON
    -- ENABLE_V4L2 = ON
    -- ENABLE_WS2812BPWM = ON
    -- ENABLE_WS281XPWM = ON
    -- ENABLE_X11 = OFF
    -- ENABLE_QT5 = OFF
    -- ENABLE_TESTS = OFF
    -- ENABLE_PROFILER = OFF
    -- Current Version: master (GitHub-69f4b32/6445c35-1481143098)
    
    CMake Warning at cmake/qt4/FindQt4.cmake:615 (message):
      /usr/bin/qmake-qt4 reported QT_INSTALL_LIBS as "/usr/lib/x86_64-linux-gnu"
      but QtCore could not be found there.  Qt is NOT installed correctly for the
      target build environment.
    Call Stack (most recent call first):
      CMakeLists.txt:154 (find_package)
    
    
    CMake Error at cmake/qt4/FindQt4.cmake:619 (message):
      Could NOT find QtCore.  Check
      /home/mint/hyperion/build-rpi/CMakeFiles/CMakeError.log for more details.
    Call Stack (most recent call first):
      CMakeLists.txt:154 (find_package)
    
    So the debian package is built ok, but the actual cross-compile fails. The paths are as follows and QT_INSTALL_LIBS is indeed that.
    Code:
    mint@mint-vb ~ $ qmake-qt4 -query
    QT_INSTALL_PREFIX:/usr
    QT_INSTALL_DATA:/usr/share/qt4
    QT_INSTALL_DOCS:/usr/share/qt4/doc
    QT_INSTALL_HEADERS:/usr/include/qt4
    QT_INSTALL_LIBS:/usr/lib/x86_64-linux-gnu
    QT_INSTALL_BINS:/usr/lib/x86_64-linux-gnu/qt4/bin
    QT_INSTALL_PLUGINS:/usr/lib/x86_64-linux-gnu/qt4/plugins
    QT_INSTALL_IMPORTS:/usr/lib/x86_64-linux-gnu/qt4/imports
    QT_INSTALL_TRANSLATIONS:/usr/share/qt4/translations
    QT_INSTALL_CONFIGURATION:/etc/xdg
    QT_INSTALL_EXAMPLES:/usr/lib/qt4/examples
    QT_INSTALL_DEMOS:/usr/lib/qt4/demos
    QMAKE_MKSPECS:/usr/share/qt4/mkspecs
    QMAKE_VERSION:2.01a
    QT_VERSION:4.8.7
    
    So at the very least, FindQt4 should be finding the soft links ?
    Code:
    mint@mint-vb ~ $ ls -la /usr/lib/x86_64-linux-gnu | grep libQtCore
    -rw-r--r--   1 root root      655 Jun  2  2016 libQtCore.prl
    lrwxrwxrwx   1 root root       18 Apr 17 20:57 libQtCore.so -> libQtCore.so.4.8.7
    lrwxrwxrwx   1 root root       18 Apr 16 10:54 libQtCore.so.4 -> libQtCore.so.4.8.7
    lrwxrwxrwx   1 root root       18 Apr 16 10:54 libQtCore.so.4.8 -> libQtCore.so.4.8.7
    -rw-r--r--   1 root root  3086448 Jun  2  2016 libQtCore.so.4.8.7
    
    Any help is appreciated.
     
  2. Akriss

    Akriss Member

    Messages:
    46
    Hardware:
    RPi1/Zero, RPi2, RPi3, 32/64bit, +Arduino
  3. TimeWalker75a

    TimeWalker75a New Member

    Messages:
    9
    Hardware:
    RPi3
    Thanks, but I wouldn't be so sure as the thread goes on to describe how to amend PATH to be able to invoke qmake, whereas I already have that working and qmake is reporting the library path to cmake by using -query. Should probably mention that qmake is just a softlink to qmake-qt4, so can call it either way as both directories are in PATH.

    Tried setting QTDIR=/usr/lib/x86_64-linux-gnu/qt4 in my .bashrc to no avail either.

    Code:
    mint@mint-vb ~ $ which qmake
    /usr/bin/qmake
    mint@mint-vb ~ $ ls -la /usr/bin/qmake
    lrwxrwxrwx 1 root root 9 Apr 17 10:34 /usr/bin/qmake -> qtchooser
    mint@mint-vb ~ $ which qmake-qt4
    /usr/bin/qmake-qt4
    mint@mint-vb ~ $ ls -la /usr/bin/qmake-qt4
    lrwxrwxrwx 1 root root 37 Jun  2  2016 /usr/bin/qmake-qt4 -> ../lib/x86_64-linux-gnu/qt4/bin/qmake
    mint@mint-vb ~ $ qmake
    Usage: /usr/lib/x86_64-linux-gnu/qt4/bin/qmake [mode] [options] [files]
    
    ...
    mint@mint-vb ~ $ qtchooser -print-env
    QT_SELECT="default"
    QTTOOLDIR="/usr/lib/x86_64-linux-gnu/qt4/bin"
    QTLIBDIR="/usr/lib/x86_64-linux-gnu"
    
    There's something else that is going on with Qt unfortunately. I had a look around for quite a while but couldn't find any indication on how to fix this.
     
    Last edited: 17 April 2017
  4. Akriss

    Akriss Member

    Messages:
    46
    Hardware:
    RPi1/Zero, RPi2, RPi3, 32/64bit, +Arduino
    You may need the QT4 Dev packages (libqt4-dev) iinstalled?
     
  5. TimeWalker75a

    TimeWalker75a New Member

    Messages:
    9
    Hardware:
    RPi3
    Indeed, except it's installed.
     
  6. TimeWalker75a

    TimeWalker75a New Member

    Messages:
    9
    Hardware:
    RPi3
    After lots of toolchain rebuilding and rsync resyncing, I made it further to
    Code:
    /home/mint/raspberrypi/rootfs/usr/include/python2.7/../stdlib.h:760:34: fatal error: bits/stdlib-bsearch.h: No such file or directory
     # include <bits/stdlib-bsearch.h>
    
    My stdlib is actually pulled into /rootfs/usr/include/arm-linux-gnueabihf, so I had to add
    Code:
    include_directories(${RASPCROSS_DIR}/rootfs/usr/include/arm-linux-gnueabihf)
    
    into cmake/Toolchain-rpi.cmake

    Now it's getting all the way to this. I'd pulled /lib and /usr from OSMC 2017.03-1 .. tried building with linaro 4.2 and 4.3, but always end up here. What is it not liking about the libs, the linked versions are all over the place?
    Code:
    Scanning dependencies of target hyperiond
    [ 95%] Building CXX object src/hyperiond/CMakeFiles/hyperiond.dir/hyperiond.cpp.o
    [ 95%] Linking CXX executable ../../bin/hyperiond
    /home/mint/raspberrypi/rootfs/usr/lib/arm-linux-gnueabihf/libpython2.7.so: undefined reference to `__fdelt_chk@GLIBC_2.15'
    /home/mint/raspberrypi/rootfs/usr/lib/arm-linux-gnueabihf/libusb-1.0.so: undefined reference to `clock_gettime@GLIBC_2.17'
    /home/mint/raspberrypi/rootfs/lib/arm-linux-gnueabihf/libudev.so.1: undefined reference to `name_to_handle_at@GLIBC_2.14'
    /home/mint/raspberrypi/rootfs/lib/arm-linux-gnueabihf/libudev.so.1: undefined reference to `secure_getenv@GLIBC_2.17'
    collect2: error: ld returned 1 exit status
    src/hyperiond/CMakeFiles/hyperiond.dir/build.make:122: recipe for target 'bin/hyperiond' failed
    make[2]: *** [bin/hyperiond] Error 1
    CMakeFiles/Makefile2:1352: recipe for target 'src/hyperiond/CMakeFiles/hyperiond.dir/all' failed
    make[1]: *** [src/hyperiond/CMakeFiles/hyperiond.dir/all] Error 2
    Makefile:149: recipe for target 'all' failed
    
     
  7. TimeWalker75a

    TimeWalker75a New Member

    Messages:
    9
    Hardware:
    RPi3
    Managed to get it building, just had to tweak the crosscompile script quite a lot. Posting just the relevant bits for RPi.
    Code:
    #ON TARGET
    #sudo apt-get install libQt4-dev libusb-1.0-0-dev rsync
    #############
    #ON HOST
    sudo apt-get update
    sudo apt-get upgrade
    sudo apt-get install git rsync cmake build-essential libqt4-dev libusb-1.0-0-dev python-dev libxrender-dev
    #########
    
    export PATH=$PATH:$HOME/raspberrypi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin
    export TARGET_IP=192.168.0.115
    export TARGET_USER=pi
    
    export RASPCROSS_DIR=$HOME/raspberrypi
    export ROOTFS_DIR=$RASPCROSS_DIR/rootfs
    export HYPERION_DIR=$HOME/hyperion
    export TOOLCHAIN_FILE=$HYPERION_DIR/cmake/Toolchain-rpi.cmake
    
    mkdir -p "$ROOTFS_DIR"
    rsync -rlP --delete-after --copy-unsafe-links $TARGET_USER@$TARGET_IP:/{lib,usr} "$ROOTFS_DIR"
    
    ######## pi specific #########
    git clone --depth 1 https://github.com/raspberrypi/firmware.git $RASPCROSS_DIR/firmware
    git clone --depth 1 https://github.com/raspberrypi/tools.git $RASPCROSS_DIR/tools
    ln -fs $RASPCROSS_DIR/firmware/hardfp/opt $ROOTFS_DIR/opt
    
    # fix libvc missing deps by linking the libs over
    ln -fs $ROOTFS_DIR/opt/vc/lib/libvcos.so $ROOTFS_DIR/usr/lib/arm-linux-gnueabihf/libvcos.so
    ln -fs $ROOTFS_DIR/opt/vc/lib/libvchiq_arm.so $ROOTFS_DIR/usr/lib/arm-linux-gnueabihf/libvchiq_arm.so
    ##### end of pi specific ######
    
    # get hyperion sources
    git clone --recursive https://github.com/hyperion-project/hyperion.git "$HYPERION_DIR"
    # fix <bits/stdlib-bsearch.h> include issues by settings SYSROOT explicitly
    grep -q "CMAKE_SYSROOT" $TOOLCHAIN_FILE
    if [ $? -ne 0 ]; then
       echo "SET(CMAKE_SYSROOT ${RASPCROSS_DIR}/rootfs)" >> $TOOLCHAIN_FILE
    fi
    # we do a native build first (to build the protobuf compiler for the native platform)
    # then for cross-build, we specify the protoc export file to import the protobuf compiler
    #
    cd $HYPERION_DIR && chmod +x bin/*.sh
    . bin/create_all_releases.sh
    
    Also builds fine with Qt 5.4.2 and Python 3.4.2 given the appropriate changed to cmake files.