Aros
Posts: 37
Joined: Tue Apr 28, 2015 9:08 am

Re: Qt5 raspbian - errors, errors and more errors :(

Fri Nov 25, 2016 10:55 am

OK, I did everything from scratch on a bigger SD card (this only delays the problem in the end it will have to fit to 1GB).

For the program to finally execute I also had to add the following packages to your script:

qt5-default
qtdeclarative5-dev
qml-module-qtquick-layouts
qml-module-qtquick-windows2
and one more, but I cannot remember which one at this point and because the app always crashed the whole system before having all the packages, the bash history was never saved during that time, therefore I cannot even back-trace which one it was.

But anyway those are specific packages used by my application, so it makes sense they are not present in your script.

Now another problem occurred (of course). When the application executes it somehow completely disables the keyboard so I cannot even shut it down with Ctrl+C and always need to reboot the whole computer. Note that the system is not frozen or something because the app still reacts to GPIO input. Any idea why it should stop reacting to the keyboard input?

And of course one huge task remains... To squeeze everything into 1GB card. If only I knew which packages I can simply remove...

And... Thanks a lot topguy, you have been of a much help to me.

Aros
Posts: 37
Joined: Tue Apr 28, 2015 9:08 am

Re: Qt5 raspbian - errors, errors and more errors :(

Mon Nov 28, 2016 11:51 pm

Finally I have solved the problem. Well, almost...

I will note the process for future generations...
To be able to install QT from twolife on my wheezy 1GB card, I had to do the following:

Here's the script:

Code: Select all

echo "mounting root and boot partitions as rw..."
echo "mounting usb drive..."
mount /dev/sda1 /media/usbstick
mkdir /media/usbstick/temp_archives
echo "cleaning apt-get cache..."
apt-get clean
echo "removing old qt5 installation..."
rm -rf /opt/qt5
echo "temporarily moving the apt-get cache to usb drive..."
cp -ax /var/cache/apt/archives /media/usbstick/temp_archives
mount --bind /media/usbstick/temp_archives/archives /var/cache/apt/archives
echo "apt-get updates of wheezy..."
apt-get update
apt-get -y --force-yes upgrade
#will need https for twolife's binaries but cannot install it afterwards when twolife's site is already a source
apt-get -y --force-yes install apt-transport-https
apt-get -y --force-yes dist-upgrade
apt-get -y --force-yes autoremove

echo "switching to jessie sources.list"
cp ./sources_jessie.list /etc/apt/sources.list
echo "jessie update..."
apt-get update
apt-get -y --force-yes upgrade
#we don't want dist-upgrade, it would take too much a space and it wouldn't fit 1GB SD
#apt-get -y --force-yes dist-upgrade
apt-get -y --force-yes autoremove
apt-get clean

echo "installing QT from twolife"
./install_qt_notools.sh
Where install_qt_no_tools.sh is topguy's script (credit goes to him...) modified for my purposes:

Code: Select all

# Add the twolife.be repository.
bash -c 'cat << EOF > /etc/apt/sources.list.d/twolife.list
# Raspbian Jessie (stable)
deb https://twolife.be/raspbian/ jessie main qt
deb-src https://twolife.be/raspbian/ jessie main qt
EOF'

apt-key adv --keyserver keyserver.ubuntu.com --recv-key 2578B775


# Install most of the needed Qt packages.
apt-get -y --force-yes install qt5-default
apt-get -y --force-yes install qml-module-qtquick2 qml
#not enough space for tools, that's 150MB (or so) package, you can uncomment it if you have large enough an SD
#apt-get -y --force-yes install qttools5-dev-tools

#depends on what packages do you use...
apt-get -y --force-yes install qtdeclarative5-dev qml-module-qtquick-layouts qml-module-qtquick-window2

# We unfortunatly have to fix some librarynames.
cp /opt/vc/lib/libGLESv2.so /opt/vc/lib/libGLESv2.so.bak
cp /opt/vc/lib/libEGL.so /usr/lib/arm-linux-gnueabihf/libEGL.so.bak

mv /opt/vc/lib/libGLESv2.so /opt/vc/lib/libGLESv2.so.2
mv /opt/vc/lib/libEGL.so /usr/lib/arm-linux-gnueabihf/libEGL.so.1
ldconfig

# Uncomment these to add some practical environment variables to every login.
cat << EOF >> ~/.profile
export QT_SELECT=5
export QT_QPA_PLATFORM=eglfs
export LD_LIBRARY_PATH=/opt/vc/lib
EOF

As for the update script:
- There are a lot of autoremoves and cleans, because there's really only 1GB SD and 100MB of this is a separate home partition, because I need the root partition to be read-only (so that it doesn't stop working for whatever reason).
- The update wouldn't not be possible without mounting the apt cache to USB drive. Again, no chance of squeezing the updates together with those really large installation packages. I think it is also faster...

As for the QT installation. First of all, I had to add qt5-default, which is the main QT package containing the most important things. Like qmake... I guess topguy was only interrested in qmlscene, so that's why he didn't have to install the main package. Also there was just no way for me to get the tools package to the SD card. At this point even without the tools, the card is 96% full. Well, since I need lrelease to build the translation resources (and guess what - yes, it is in tools package with 150MB of other stuff) I did a simple trick. I installed it on another SD card where I didn't put the other packages, and then copied just the lrelease binary to my main installation.

This whole process took me about a week of tedious work. It was a martyr and was totally not worth it. I sweared like a sailor cursing Linux all the time but finally it works. Well at the beginning I said almost... Yes, there are two more things, that were not there before, I need to cope with. So:

(QUESTION)

1) viewtopic.php?f=31&t=166647
2) I have an entry in bashrc that is supposed to launch my QT app right after boot, it looks like this:

Code: Select all

(cd ~/my/path && exec ~/my/path/mybinary )
But this time I get this error right when I boot to the shell:
/root/my/path/mybinary: error while loading shared libraries: libGLESv2.so.2: cannot open shared object file: No such file or directory
Well, that's the kind of error you would get if you didn't apply the fix from the topguy's script. But I did. And I can launch the application manually without any problem. It just stopped working when called from bashrc. Any ideas?

blumble-pi
Posts: 6
Joined: Tue Jul 31, 2012 7:13 am

Re: Qt5 raspbian - errors, errors and more errors :(

Tue Nov 29, 2016 8:06 am

Aros wrote:[...]
2) I have an entry in bashrc that is supposed to launch my QT app right after boot, it looks like this:

Code: Select all

(cd ~/my/path && exec ~/my/path/mybinary )
But this time I get this error right when I boot to the shell:
/root/my/path/mybinary: error while loading shared libraries: libGLESv2.so.2: cannot open shared object file: No such file or directory
Well, that's the kind of error you would get if you didn't apply the fix from the topguy's script. But I did. And I can launch the application manually without any problem. It just stopped working when called from bashrc. Any ideas?
I suposse, the enviroment variables (QT_*, LD_LIBRAR_PATH) are not set, when you launch your app from bashrc. And think about to add the path /opt/vc/lib/ to your /etc/ld.so.conf (or better as file into /etc/ld.so.conf.d/*)

Aros
Posts: 37
Joined: Tue Apr 28, 2015 9:08 am

Re: Qt5 raspbian - errors, errors and more errors :(

Tue Nov 29, 2016 10:05 pm

Yes, of course you are right. I found that myself just a while after I posted the question. It is obvious. The content of the .profile, where the env variables are set is loaded after the .bashrc script is executed. I will try you solution and let you know. Thanks.

blumble-pi
Posts: 6
Joined: Tue Jul 31, 2012 7:13 am

Re: Qt5 raspbian - errors, errors and more errors :(

Wed Nov 30, 2016 7:51 am

Just create a simple shell script, where you setup environment and call "yourbinary", and then call this script from .bashrc (or wherever you want). The goal is, you bundle all that "yourbinary" needs tu run in one place and don't affect (global) environments for other programs

User avatar
jeanleflambeur
Posts: 157
Joined: Mon Jun 16, 2014 6:07 am
Contact: Website

Re: Qt5 raspbian - errors, errors and more errors :(

Wed Nov 30, 2016 8:45 am

If you're using QT creator to cross-compile for the PI and to debug remotely you will have an issue with the host gdb being compiled without python support - on Ubuntu at least.

The solution is to install gdb-multiarch on the host and configure it as the debugger for the kit, as detailed here: https://jeanleflambeur.wordpress.com/20 ... qtcreator/

Aros
Posts: 37
Joined: Tue Apr 28, 2015 9:08 am

Re: Qt5 raspbian - errors, errors and more errors :(

Wed Nov 30, 2016 10:35 am

I have created a qt.conf file in the /etc/ld.so.conf.d as you advised and put the /opt/vc/lib path there. But it didn't help. But when I put:

Code: Select all

export LD_LIBRARY_PATH=/opt/vc/lib
right before calling the application in .bashrc, it works. As the sole purpose of the whole OS is just to run this one application, I am probably not going to bother about affecting other programs at this point. Thanks for the help.

jeanleflambeur: No, not a problem. I am developing the application in VS plugin and build it on Windows and I also do all the debugging there. When I'm happy with the update, I just build the application directly on Raspberry using qmake, g++ and make. So far, I was not in a need of debugging on Raspberry. Debugging in VS is very convenient. There were some platform specific problems but I was always able to find out what's the problem by just knowing what I had changed in the last commit...

Big thanks to all of you guys for your help!

blumble-pi
Posts: 6
Joined: Tue Jul 31, 2012 7:13 am

Re: Qt5 raspbian - errors, errors and more errors :(

Thu Dec 01, 2016 8:43 am

Aros wrote:I have created a qt.conf file in the /etc/ld.so.conf.d as you advised and put the /opt/vc/lib path there. But it didn't help.
Did you call ldconfig or restart pi for refreshing the loader cache ? You can check with "ldconfig -p", if libraries from /opt/vc/lib are listed.
Aros wrote:But when I put:

Code: Select all

export LD_LIBRARY_PATH=/opt/vc/lib
right before calling the application in .bashrc, it works.
If you have installed MESA (or other OpenGL like package), you allready have a libGLESv2.so.X in your /usr/lib (or elsewhere). With LD_LIBRARY_PATH you can define folders, from there libraries shold be take first (see also here, section 3.2 and 3.3)

User avatar
topguy
Posts: 5687
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: Qt5 raspbian - errors, errors and more errors :(

Thu Dec 01, 2016 2:19 pm

> If you have installed MESA (or other OpenGL like package), you allready have a libGLESv2.so.X in your /usr/lib (or elsewhere).

Yes, but the whole point here is to NOT use them because they don't work. That is why we are forcing dynamic linking with the ones in "/opt/vc".

Return to “Raspbian”