Reputation: 415
I develop software in Qt for a microcomputer based on Cortex imx6. On this platform, I have installed Linux prepared for this uP and Qt.
uname -a
Linux colibri-imx6 4.1.35-v2.7b1+gc1177831f5a1 #11 SMP Tue Jun 20 13:05:01 CEST 2017 armv7l armv7l armv7l GNU/Linux
I want to run my app during system startup and I have a problem with this. I wrote a basic service for this:
/etc/init.d/panel-service.sh
:
#!/bin/sh
### BEGIN INIT INFO
# Provides: panel-service.sh
# Required-Start: $remote_fs $syslog $all
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Service to autorun app during system starting.
### END INIT INFO
### START config here:
BUSAGE="usage: $0 {start|stop}";
### END config here.
usage(){
echo $USAGE >&2
}
start(){
echo "Start panel service"
sh /home/root/panel.sh
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
usage
exit 1
;;
esac
/home/root/panel.sh
:
#!/bin/sh
echo "Script is already run"
/home/root/panel
After rebooting my device, I got an error:
QML debugging is enabled. Only use this in a safe environment. This application failed to start because it could not find or load the Qt platform plugin "xcb" in "".
Available platform plugins are: eglfs, minimal, minimalegl, offscreen.
Reinstalling the application may fix this problem. /media/sdcard/panel.sh: line 11: 410 Aborted panel
/home/root/panel
It's strange, because my app don't use libxcb.so...
ldd panel
libudev.so.1 => /lib/libudev.so.1 (0x76ea0000)
libblkid.so.1 => /lib/libblkid.so.1 (0x76e5c000)
libQt5Quick.so.5 => /usr/lib/libQt5Quick.so.5 (0x76b56000)
libQt5Widgets.so.5 => /usr/lib/libQt5Widgets.so.5 (0x76645000)
libQt5Gui.so.5 => /usr/lib/libQt5Gui.so.5 (0x761d4000)
libQt5Qml.so.5 => /usr/lib/libQt5Qml.so.5 (0x75e84000)
libQt5Network.so.5 => /usr/lib/libQt5Network.so.5 (0x75d34000)
libQt5Core.so.5 => /usr/lib/libQt5Core.so.5 (0x7587b000)
libpthread.so.0 => /lib/libpthread.so.0 (0x75853000)
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x7570d000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x756e1000)
libc.so.6 => /lib/libc.so.6 (0x755a5000)
/lib/ld-linux-armhf.so.3 (0x76edc000)
libuuid.so.1 => /lib/libuuid.so.1 (0x75592000)
libGLESv2.so.2 => /usr/lib/libGLESv2.so.2 (0x75499000)
libm.so.6 => /lib/libm.so.6 (0x7541b000)
libharfbuzz.so.0 => /usr/lib/libharfbuzz.so.0 (0x7539b000)
libz.so.1 => /lib/libz.so.1 (0x75379000)
libpng16.so.16 => /usr/lib/libpng16.so.16 (0x75341000)
libicui18n.so.57 => /usr/lib/libicui18n.so.57 (0x75148000)
libicuuc.so.57 => /usr/lib/libicuuc.so.57 (0x74feb000)
libdl.so.2 => /lib/libdl.so.2 (0x74fd8000)
libglib-2.0.so.0 => /usr/lib/libglib-2.0.so.0 (0x74ed9000)
librt.so.1 => /lib/librt.so.1 (0x74ec2000)
libGAL.so => /usr/lib/libGAL.so (0x74dbe000)
libEGL.so.1 => /usr/lib/libEGL.so.1 (0x74d9e000)
libVSC.so => /usr/lib/libVSC.so (0x74cdc000)
libpcre.so.1 => /usr/lib/libpcre.so.1 (0x74c8d000)
libfreetype.so.6 => /usr/lib/libfreetype.so.6 (0x74c07000)
libicudata.so.57 => /usr/lib/libicudata.so.57 (0x7337b000)
I tried to add script to /etc/profile.d
with the same error and I set auto log on root during system loading, but with no other results. When I run app or service after full system load from terminal, everything works fine and the app starts, so I have all of the necessary libraries. I don't know why it doesn't start after reboot.
Differents in env between time, when script is call and full system load. Script call moment:
CONSOLE=/dev/console
TERM=linux
SHELL=/bin/sh
OLDPWD=/
INIT_VERSION=sysvinit-2.88
PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin
RUNLEVEL=5
runlevel=5
PWD=/media/sdcard
VERBOSE=no
PREVLEVEL=N
previous=N
fbmem=24M
HOME=/
SHLVL=2
fec_mac=00:14:2d:4a:4a:cb
enable_wait_mode=off
_=/usr/bin/env
After system load:
HZ=100
SHELL=/bin/sh
TERM=linux
HUSHLOGIN=FALSE
USER=root
PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin
QT_QPA_EGLFS_FORCE888=1
PWD=/home/root
EDITOR=vi
QT_QPA_EGLFS_PHYSICAL_WIDTH=154
QT_QPA_PLATFORM=eglfs
PS1=\u@\h:\w\$
QT_QPA_EGLFS_FORCEVSYNC=1
SHLVL=1
HOME=/home/root
LOGNAME=root
QT_QPA_EGLFS_PHYSICAL_HEIGHT=85
_=/usr/bin/env
Can I set QT env variables which aren't set during system starting?
Upvotes: 1
Views: 699
Reputation: 415
In my case the point is to set Qt env
variables in bash script using export
.
Below last version of my script:
#!/bin/bash
PATH=$PATH:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
export QT_QPA_EGLFS_FORCE888=1
export QT_QPA_EGLFS_PHYSICAL_WIDTH=154
export QT_QPA_PLATFORM=eglfs
export QT_QPA_EGLFS_FORCEVSYNC=1
export QT_QPA_EGLFS_PHYSICAL_HEIGHT=85
export QT_PLUGIN_PATH=/usr/lib/qt5/plugins
echo "Script is already run"
cd /home/root/
panel
It work like a charm. :)
Upvotes: 1
Reputation: 4582
The header in your /home/root/panel.sh
is wrong, corrected as below. Also its import to make sure of env
settings mainly $PATH
variable.
You can correct it in your script by explicitly adding the needed PATH to your script, for example:
#!/bin/bash
PATH=$PATH:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
echo "Script is already run"
/home/root/panel
Upvotes: 0