Error while cross compiling Qt for a raspberry pi3

倾然丶 夕夏残阳落幕 提交于 2019-12-11 15:30:53

问题


I want to cross compile Qt to develop a gui for a raspberry pi. I have been following this tutorial: https://wiki.qt.io/RaspberryPi2EGLFS

I am using this configure command:

./configure -release -opengl es2 -device linux-rasp-pi3-g++ -device-option \
CROSS_COMPILE=~/raspi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf- \
-sysroot ~/raspi/sysroot -opensource -confirm-license \
-make libs -no-use-gold-linker -prefix /usr/local/qt5pi \
-extprefix ~/raspi/qt5pi -hostprefix ~/raspi/qt5 -v

This is the error I'm getting back:

/home/vbox/raspi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf-g++ -mfloat-abi=hard --sysroot=/home/vbox/raspi/sysroot -Wl,-O1 -Wl,-rpath-link,/home/vbox/raspi/sysroot/opt/vc/lib -Wl,-rpath-link,/home/vbox/raspi/sysroot/usr/lib/arm-linux-gnueabihf -Wl,-rpath-link,/home/vbox/raspi/sysroot/lib/arm-linux-gnueabihf -o verifyspec verifyspec.o    
/home/vbox/raspi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/../lib/gcc/arm-linux-gnueabihf/4.8.3/../../../../arm-linux-gnueabihf/bin/ld: cannot find crt1.o: No such file or directory
/home/vbox/raspi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/../lib/gcc/arm-linux-gnueabihf/4.8.3/../../../../arm-linux-gnueabihf/bin/ld: cannot find crti.o: No such file or directory
/home/vbox/raspi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/../lib/gcc/arm-linux-gnueabihf/4.8.3/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lm
 collect2: error: ld returned 1 exit status
 Makefile:66: recipe for target 'verifyspec' failed
 make: *** [verifyspec] Error 1
Note: Also available for Linux: linux-clang linux-icc
ERROR: Cannot compile a minimal program. The toolchain or QMakeSpec is broken.`

This is the config.log:

vbox@vbox:~/qtbase$ cat config.log
Command line: -release -opengl es2 -device linux-rasp-pi3-g++ -device-option CROSS_COMPILE=/home/vbox/raspi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf- -sysroot /home/vbox/raspi/sysroot -opensource -confirm-license -make libs -no-use-gold-linker -prefix /usr/local/qt5pi -extprefix /home/vbox/raspi/qt5pi -hostprefix /home/vbox/raspi/qt5 -v
executing config test machineTuple
+ /home/vbox/raspi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf-g++ -dumpmachine
 arm-linux-gnueabihf
test config.qtbase.tests.machineTuple succeeded
executing config test verifyspec
+ cd /home/vbox/qtbase/config.tests/verifyspec && /home/vbox/qtbase/bin/qmake "CONFIG -= qt debug_and_release app_bundle lib_bundle" "CONFIG += shared warn_off console single_arch" "QMAKE_CFLAGS += --sysroot=/home/vbox/raspi/sysroot" "QMAKE_CXXFLAGS += --sysroot=/home/vbox/raspi/sysroot" "QMAKE_LFLAGS += --sysroot=/home/vbox/raspi/sysroot" -early "CONFIG += cross_compile" /home/vbox/qtbase/config.tests/verifyspec
 Info: creating stash file /home/vbox/qtbase/config.tests/.qmake.stash
+ cd /home/vbox/qtbase/config.tests/verifyspec && MAKEFLAGS= /usr/bin/make
 /home/vbox/raspi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf-g++ -c -march=armv8-a -mtune=cortex-a53 -mfpu=crypto-neon-fp-armv8 -mfloat-abi=hard --sysroot=/home/vbox/raspi/sysroot -O2 -std=gnu++11 -w -fPIC  -I. -I/home/vbox/qtbase/mkspecs/devices/linux-rasp-pi3-g++ -o verifyspec.o verifyspec.cpp
 /home/vbox/raspi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf-g++ -mfloat-abi=hard --sysroot=/home/vbox/raspi/sysroot -Wl,-O1 -Wl,-rpath-link,/home/vbox/raspi/sysroot/opt/vc/lib -Wl,-rpath-link,/home/vbox/raspi/sysroot/usr/lib/arm-linux-gnueabihf -Wl,-rpath-link,/home/vbox/raspi/sysroot/lib/arm-linux-gnueabihf -o verifyspec verifyspec.o    /home/vbox/raspi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/../lib/gcc/arm-linux-gnueabihf/4.8.3/../../../../arm-linux-gnueabihf/bin/ld: cannot find crt1.o: No such file or directory
 /home/vbox/raspi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/../lib/gcc/arm-linux-gnueabihf/4.8.3/../../../../arm-linux-gnueabihf/bin/ld: cannot find crti.o: No such file or directory
 /home/vbox/raspi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/../lib/gcc/arm-linux-gnueabihf/4.8.3/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lm
 collect2: error: ld returned 1 exit status
 Makefile:66: recipe for target 'verifyspec' failed
 make: *** [verifyspec] Error 1

I'm not sure where to go from here, I don't know enough to start debugging this issue. Are there alternate toolchains available? Or is the issue with the QMakeSpec? Any suggestions on things to try would be very helpful.


回答1:


This blog post seems more specific to RPi3, and probably does it too (last Jan 12, 2017):

https://medium.com/@amirmann/how-to-cross-compile-qt-for-raspberry-pi-3-on-linux-ubuntu-for-beginners-75acf2a078c

sudo apt-get upgrade
sudo apt-get update
sudo apt-get install libgl1-mesa-dev
...
sudo apt-get build-dep qt5-default
sudo apt-get install libxcb-xinerama0-dev
sudo apt-add-repository ppa:u-szeged/sedkit
sudo apt-get update
sudo apt-get install sedkit-env-qtwebkit
sudo apt-get install build-essential perl python git
sudo apt-get install “^libxcb.*” libx11-xcb-dev libglu1-mesa-dev libxrender-dev libxi-dev
sudo apt-get install flex bison gperf libicu-dev libxslt-dev ruby
sudo apt-get install libssl-dev libxcursor-dev libxcomposite-dev libxdamage-dev libxrandr-dev libfontconfig1-dev libcap-dev libxtst-dev libpulse-dev libudev-dev libpci-dev libnss3-dev libasound2-dev libxss-dev libegl1-mesa-dev gperf bison
sudo apt-get install libbz2-dev libgcrypt11-dev libdrm-dev libcups2-dev libatkmm-1.6-dev
sudo apt-get install libasound2-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev

There is a note on the wiki you are looking at of some things they did to get it to work on newer builds. Here is some of the history of that wiki page:

https://wiki.qt.io/index.php?title=RaspberryPi2EGLFS&type=revision&diff=31538&oldid=30634

And then there is the device creation licensed version of Qt then you would use these instructions:

http://doc.qt.io/QtForDeviceCreation/qtee-preparing-hardware-rasberrypi.html

I have always learned a lot while digging into the articles on Linux from Scratch. In my recent building of Qt with nothing, they have been super helpful.

http://www.linuxfromscratch.org/blfs/view/8.0/x/qt5.html

Hope those links help.




回答2:


This is my bash script for cross-compiling Qt for raspberry-pi. You can this script with command <script name> <TcpIp of Raspberrry> $USER

#!/bin/bash
RASP_ADR=$1
USERNAME=$2
if [ ! $RASP_ADR ] 
then
        echo "Error: need Ip address"
    exit 1
fi

LOGFILE=install.log.txt
rm -f $LOGFILE

ID_RSA=/root/.ssh/cu4_rsa

SSH="ssh -i $ID_RSA root@$RASP_ADR"

DEST=~/raspi

QT_VERSION=5.9

function log {
    local t=`date`
        echo "[$t] $@" | tee -a $LOGFILE
}

function remote_src {
        local message
        local exitcode
        message=$1
        shift
        log $message
        log "Remote $RASP_ADR command: $@"
        OUT=`$SSH "$@" | tee /dev/tty | tee -a $LOGFILE`
        exitcode=$?
        if [ $exitcode -ne 0 ]; then
                log "Exit with ERROR $exitcode"
                exit $exitcode
        fi
}

function local_src {
        local message
        local exitcode
        message=$1
        shift
        log $message
        log "Local command: $@"
        OUT=`bash -c "$@" | tee /dev/tty | tee -a $LOGFILE`
        exitcode=$?
        if [ $exitcode -ne 0 ]; then
                log "Exit with ERROR $exitcode"
                exit $exitcode
        fi
}

function Append_Qt_Module {
        local QtModule
        QtModule=$1
        log "install $QtModule"
        local_src \
        "Clone $QtModule Qt-module" \
        "cd $DEST && git clone git://code.qt.io/qt/$QtModule.git -b $QT_VERSION"
        local_src \
        "Make $QtModule Qt-module" \
        "cd $DEST/$QtModule && $DEST/qt5/bin/qmake -r && make && make install"
        local_src \
        "Synchronize qt5pi with Raspberry pi" \
        "rsync -avz -e \"ssh -i $ID_RSA\" $DEST/qt5pi pi@$RASP_ADR:/usr/local"
}

local_src \
"open key -> Raspberry" \
"cat /root/.ssh/cu4_rsa.pub | ssh pi@$RASP_ADR \"sudo cat - > authorized_keys; sudo mkdir -p /root/.ssh; sudo mv authorized_keys /root/.ssh; sudo chown -R root:root /root/.ssh\""

remote_src \
"Update System" \
"apt-get update"

remote_src \
"Upgrade System" \
"apt-get -y upgrade"

remote_src \
"Install Synaptic" \
"apt-get -y install synaptic"

remote_src \
"Install Qt libraries" \
"apt-get -y install libfontconfig1-dev libdbus-1-dev libudev-dev"

remote_src \
"Install Xcb" \
"apt-get -y install \"^libxcb.*\" libx11-xcb-dev libglu1-mesa-dev libxrender-dev libxi-dev"

remote_src \
"Install Qt-WebKit" \
"apt-get -y install flex bison gperf libicu-dev libxslt-dev ruby"

remote_src \
"Install Qt WebEngine" \
"apt-get -y install libssl-dev libxcursor-dev libxcomposite-dev libxrandr-dev"

remote_src \
"Install Qt Multimedia" \
"apt-get -y install libasound2-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev"

DEB_SRC="deb-src http://archive.raspbian.org/raspbian/ jessie main contrib non-free rpi"
remote_src \
"Проверка открытости deb_src" \
"cat /etc/apt/sources.list | grep -s -G '^$DEB_SRC' | cat"

if [ ! "$OUT" ]
then
    remote_src \
    "Открываем комментарии" \
    "echo '$DEB_SRC' >> /etc/apt/sources.list"
else
    log "DEB_SRC открыты ранее"
fi

remote_src \
"Update System" \
"apt-get update"

remote_src \
"Build dependences for qt4-x11" \
"apt-get -y build-dep qt4-x11"

remote_src \
"Build dependences for libqt5gui5" \
"apt-get -y build-dep libqt5gui5"

remote_src \
"Install more libs for Xcb" \
"apt-get -y install libinput-dev libts-dev libxcb-xinerama0-dev libxcb-xinerama0"

remote_src \
"Make dir for Qt libs" \
"mkdir /usr/local/qt5pi; chown pi:pi /usr/local/qt5pi"

remote_src \
"Reboot" \
"reboot"

while true; do
    sleep 1s
    log "wait..."
    $SSH "echo done"
    if [ $? -eq 0 ]; then break; fi
done

local_src \
"Install Git" \
"apt-get -y install git && mkdir -p $DEST && cd $DEST"

local_src \
"Clone RaspberryPi tools" \
"git clone https://github.com/raspberrypi/tools $DEST/tools"

local_src \
"OR Update Raspberry Pi Tools" \
"cd $DEST/tools && git pull origin master"

fi

local_src \
"Synchronize local computer with Raspberry Pi" \
"cd $DEST && mkdir -p /sysroot /sysroot/usr /sysroot/opt && \
rsync -avz -e \"ssh -i $ID_RSA\" root@$RASP_ADR:/lib sysroot && \
rsync -avz -e \"ssh -i $ID_RSA\" root@$RASP_ADR:/usr/include sysroot/usr && \
rsync -avz -e \"ssh -i $ID_RSA\" root@$RASP_ADR:/usr/lib sysroot/usr  && \
rsync -avz -e \"ssh -i $ID_RSA\" root@$RASP_ADR:/opt/vc sysroot/opt && \
rsync -avz -e \"ssh -i $ID_RSA\" root@$RASP_ADR:/usr/local/include sysroot/usr/local && \
rsync -avz -e \"ssh -i $ID_RSA\" root@$RASP_ADR:/usr/local/lib sysroot/usr/local"

local_src \
"Get sysroot-relative.py script" \
"cd $DEST && wget https://raw.githubusercontent.com/riscv/riscv-poky/master/scripts/sysroot-relativelinks.py && \
chmod +x sysroot-relativelinks.py && \
./sysroot-relativelinks.py sysroot "
exit 0

local_src \
"Получаем qtbase версии $QT_VERSION и конфигурируем Qt."
"`git clone -b $QT_VERSION git://code.qt.io/qt/qtbase.git  $DEST/qtbase`"
local_src \
"OR Update qtbase версии $QT_VERSION" \
"cd $DEST/qtbase && git pull origin $QT_VERSION"

local_src \
"Конфигурация и установка Qt$QT_VERSION" \
"cd $DEST/qtbase && ./configure -release -opengl es2 -device linux-rasp-pi3-g++ \
-device-option CROSS_COMPILE=$DEST/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf- \
-sysroot $DEST/sysroot -opensource -confirm-license -make libs -make tools -qt-pcre -optimized-qmake -reduce-exports \
-release -prefix /usr/local/qt5pi -extprefix $DEST/qt5pi -hostprefix $DEST/qt5 -no-use-gold-linker -v && \
make -j 4 && make install"

local_src \
"Change owner to $USERNAME on $DEST" \
"chown -R $USERNAME:$USERNAME $DEST"

local_src \
"Get new free types from http://dejavu-fonts.org" \
"cd $DEST && wget http://sourceforge.net/projects/dejavu/files/dejavu/2.37/dejavu-fonts-ttf-2.37.tar.bz2 && \
tar -xvf dejavu-fonts-ttf-2.37.tar.bz2"

local_src \
"Send type to target dir" \
"cd $DEST && mkdir -p qt5pi/lib/fonts && \
cp dejavu-fonts-ttf-2.37/ttf/DejaVuSansMono.ttf qt5pi/lib/fonts/"

local_src \
"Send libs to RaspberryPi" \

"cd $DEST && rsync -avz -e \"ssh -i $ID_RSA\" qt5pi root@$RASP_ADR:/usr/local"

local_src \
"Build Test application" \
"cd $DEST/qtbase/examples/opengl/qopenglwidget && \
$DEST/qt5/bin/qmake && \
make && \
scp -i $ID_RSA qopenglwidget root@$RASP_ADR:/home/pi "

remote_src \
"Добавляем пути к библиотекам Qt на Raspberry Pi" \
"echo /usr/local/qt5pi/lib | tee /etc/ld.so.conf.d/qt5pi.conf && \
ldconfig"

remote_src \
"Устранение неполадок в библиотеке EGL/GLES " \
"rm /usr/lib/arm-linux-gnueabihf/libEGL.so.1.0.0 /usr/lib/arm-linux-gnueabihf/libGLESv2.so.2.0.0 && \
ln -s /opt/vc/lib/libEGL.so /usr/lib/arm-linux-gnueabihf/libEGL.so.1.0.0 && \
ln -s /opt/vc/lib/libGLESv2.so /usr/lib/arm-linux-gnueabihf/libGLESv2.so.2.0.0 && \
ln -s /opt/vc/lib/libEGL.so /opt/vc/lib/libEGL.so.1 && \
ln -s /opt/vc/lib/libGLESv2.so /opt/vc/lib/libGLESv2.so.2"


remote_src \
"Запуск теста" \
"nohup /home/pi/qopenglwidget > /dev/null 2>&1 &"

log "Please push the some key when you are ready to next operation"
read -n1

remote_src \
"Kill test" \
"pkill qopenglwidget"

#Add youre Qt modules
Append_Qt_Module qtserialport

remote_src \
"Обновляем символьные линки к  библиотекам Qt на Raspberry Pi" \
"ldconfig"

log "DONE!!!!"
exit 0



回答3:


I edited device mkspec file linux-rasp-pi3-g++/qmake.conf like this

VC_LIBRARY_PATH         = $$[QT_SYSROOT]/opt/vc/lib
VC_INCLUDE_PATH         = $$[QT_SYSROOT]/opt/vc/include

QMAKE_LIBDIR_OPENGL_ES2 = $${VC_LIBRARY_PATH}
QMAKE_LIBDIR_EGL        = $$QMAKE_LIBDIR_OPENGL_ES2
QMAKE_LIBDIR_OPENVG     = $$QMAKE_LIBDIR_OPENGL_ES2

QMAKE_INCDIR_EGL        = \
                        $${VC_INCLUDE_PATH} \
                        $${VC_INCLUDE_PATH}/interface/vcos/pthreads \
                        $${VC_INCLUDE_PATH}/interface/vmcs_host/linux
QMAKE_INCDIR_OPENGL_ES2 = $${QMAKE_INCDIR_EGL}
QMAKE_INCDIR_OPENVG     = $${QMAKE_INCDIR_EGL}

QMAKE_LIBS_OPENGL_ES2   = -lGLESv2
QMAKE_LIBS_EGL          = -lEGL -lGLESv2
QMAKE_LIBS_OPENVG       = -lEGL -lOpenVG -lGLESv2

and use gcc-linaro-4.9-2015.02-3-x86_64_arm-linux-gnueabihf toolchain.

I wrote this blog which may be helpful: Build Qt 5.10 for Raspberry Pi 3



来源:https://stackoverflow.com/questions/46654778/error-while-cross-compiling-qt-for-a-raspberry-pi3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!