Recent

Author Topic: Yocto Recipe for libQt5Pas  (Read 7173 times)

BasePointer

  • New Member
  • *
  • Posts: 14
Yocto Recipe for libQt5Pas
« on: January 14, 2022, 12:28:05 am »
Hi,

I have a board from Toradex which runs custom Yocto build Linux on a iMX8M-Plus processor.  (aarch64)
I use their tdx-reference-multimedia-image which has Graphics stack: Weston / Wayland + XWayland and Graphical User Interface framework: Qt5 and it runs Qt5 applications nicely.

What I want is to run Lazarus Application uses Qt5 widgetset.
First, I followed instructions here: https://developer.toradex.com/knowledge-base/lazarus and installed Lazarus v2.3.0 on my Win10 machine with cross compilers.
Then, I created a simple LCL Form app, add a simple button to say hello when it is pressed. Then I set the WidgetType to Qt5 and Target: Linux and CPU: aarch64. It is compiled and project1 executable created.
I copied it to the Toradex board and when I run of course I got a lot of library missing error. So far expected..

Luckily I found all required libraries as compiled under Lazarus\cross\lib\aarch64-linux folder but sure it would be too easy if all they worked :) They created a lot of incompatibilities and embedded system Linux crashed eventually.

So I decided to add each library required by Lazarus app into Toradex Yocto Image so that they can be compiled fully for my system.

Here is the list of recipes required by Lazarus App:
    libmd
    libgssglue
    zstd
    krb5
    keyutils
You can check each of them here: https://layers.openembedded.org/layerindex/branch/master/recipes/

One thing remains pain for me which is libQt5Pas. It is not a standard recipe as others and no ready bitbake file which yocto can build, generate and integrate it into the linux image automatically.
So I made one. I took the source code of libQt5Pas from .\lazarus\lcl\interfaces\qt5\cbindings and created libqt5pas.bb file as below:
Code: Text  [Select][+][-]
  1. #
  2. # Build libQt5Pas
  3. #
  4.  
  5. SUMMARY = "libQt5Pas for Lazarus"
  6. SECTION = "libs"
  7. LICENSE = "LGPLv3"
  8. LIC_FILES_CHKSUM = "file://COPYING.TXT;md5=5d5b6fbba1566704ccfaecd6eb49518f"
  9.  
  10. DEPENDS = "qtbase qtx11extras"
  11.  
  12. S = "${WORKDIR}"
  13.  
  14. SRC_URI += "file://Qt5Pas.pro"
  15. SRC_URI += "file://*.txt"
  16. SRC_URI += "file://*.pas"
  17. SRC_URI += "file://src/*.h"
  18. SRC_URI += "file://src/*.cpp"
  19. SRC_URI += "file://src/*.c"
  20.  
  21.  
  22. inherit qmake5

And finally when I execute bitbake libqt5pas, I get:
Quote
In file included from ../src/qsessionmanager_c.cpp:12:
../src/qsessionmanager_c.h:24:88: error: 'QSessionManager::RestartHint' has not been declared
   24 | C_EXPORT void QSessionManager_setRestartHint(QSessionManagerH handle, QSessionManager::RestartHint AnonParam1);
      |                                                                                        ^~~~~~~~~~~
compilation terminated due to -Wfatal-errors.
make: *** [Makefile:41001: tmp/qsessionmanager_c.o] Error 1
make: *** Waiting for unfinished jobs....
../src/qguiapplication_c.cpp: In function 'bool QGuiApplication_isSessionRestored(QGuiApplicationH)':
../src/qguiapplication_c.cpp:211:45: error: 'class QGuiApplication' has no member named 'isSessionRestored'
  211 |  return (bool) ((QGuiApplication *)handle)->isSessionRestored();
      |                                             ^~~~~~~~~~~~~~~~~
compilation terminated due to -Wfatal-errors.
make: *** [Makefile:41294: tmp/qguiapplication_c.o] Error 1
ERROR: oe_runmake failed

Any idea why it could be?

Thank you.

-------------------

More digging about Qt5 version available in the system.

I use Yocto Dunfell which has qtbase 5.14.2 recipe. Therefor whole embedded linux system has Qt5 v5.14.2.
As I understand the latest libQt5Pas codes for Qt5 v5.6 LTS. (released in 2016 and obsolete in 2019).

I believe that above compiler error is caused because of version incompatibilities between Qt v5.6 and v5.14.
Now I see two paths to go.
Do you think that I shall try to downgrade whole Qt5 version in my yocto linux from 5.14 to 5.6 or
I shall try to upgrade libQt5Pas code to support Qt5 v5.14?

Thank you.

« Last Edit: January 14, 2022, 10:02:39 am by BasePointer »

zeljko

  • Hero Member
  • *****
  • Posts: 1257
    • http://wiki.lazarus.freepascal.org/User:Zeljan
Re: Yocto Recipe for libQt5Pas
« Reply #1 on: January 14, 2022, 09:53:16 am »
maybe qtcore and qtx11extras isn't enough....try to add qtwidgets and/or qtgui

BasePointer

  • New Member
  • *
  • Posts: 14
Re: Yocto Recipe for libQt5Pas
« Reply #2 on: January 14, 2022, 11:54:14 am »
maybe qtcore and qtx11extras isn't enough....try to add qtwidgets and/or qtgui

Thank you for the suggestion.

As I see qtbase adds all required except Qt5X11Extras that's why I added it.

here is the details
Code: Text  [Select][+][-]
  1. 'qtbase': 'Qt5 Qt5Concurrent Qt5Core Qt5DBus Qt5Gui Qt5Network Qt5OpenGL Qt5OpenGLExtensions Qt5PrintSupport Qt5Sql Qt5Test Qt5Widgets Qt5Xml',
  2. 'qtsvg': 'Qt5Svg',
  3. 'qtdeclarative': 'Qt5Qml Qt5Quick Qt5QuickWidgets Qt5QuickTest',
  4. 'qtxmlpatterns': 'Qt5XmlPatterns',
  5. 'qtsystems': 'Qt5PublishSubscribe Qt5ServiceFramework Qt5SystemInfo',
  6. 'qtscript': 'Qt5Script Qt5ScriptTools',
  7. 'qttools': 'Qt5Designer Qt5Help Qt5LinguistTools Qt5UiPlugin Qt5UiTools',
  8. 'qtenginio': 'Qt5Enginio',
  9. 'qtsensors': 'Qt5Sensors',
  10. 'qtmultimedia': 'Qt5Multimedia Qt5MultimediaWidgets',
  11. 'qtwebchannel': 'Qt5WebChannel',
  12. 'qtwebsockets': 'Qt5WebSockets',
  13. 'qtserialport': 'Qt5SerialPort',
  14. 'qtx11extras': 'Qt5X11Extras',
  15. 'qtlocation': 'Qt5Location Qt5Positioning',
  16. 'qt3d': 'Qt53DCollision Qt53DCore Qt53DInput Qt53DLogic Qt53DQuick Qt53DQuickRender Qt53DRender'


BasePointer

  • New Member
  • *
  • Posts: 14
Re: Yocto Recipe for libQt5Pas
« Reply #3 on: January 14, 2022, 02:44:06 pm »
Hello,

I stuck at the same problem. I have decided to compile it manually first. But it ends up with the same error.
I have installed qt5sdk and followed instructions in README.TXT in cbindings.

1. qmake -query
Code: [Select]
mf@linux:~/yocto-projects/qt5sdk/cbindings$ qmake -query
QT_SYSROOT:/home/mf/yocto-projects/qt5sdk/sysroots/aarch64-tdx-linux
QT_INSTALL_PREFIX:/home/mf/yocto-projects/qt5sdk/sysroots/aarch64-tdx-linux/usr
QT_INSTALL_PREFIX/raw:/usr
QT_INSTALL_ARCHDATA:/home/mf/yocto-projects/qt5sdk/sysroots/aarch64-tdx-linux/usr/lib
QT_INSTALL_ARCHDATA/raw:/usr/lib
QT_INSTALL_DATA:/home/mf/yocto-projects/qt5sdk/sysroots/aarch64-tdx-linux/usr/share
QT_INSTALL_DATA/raw:/usr/share
QT_INSTALL_DOCS:/home/mf/yocto-projects/qt5sdk/sysroots/aarch64-tdx-linux/usr/share/doc
QT_INSTALL_DOCS/raw:/usr/share/doc
QT_INSTALL_HEADERS:/home/mf/yocto-projects/qt5sdk/sysroots/aarch64-tdx-linux/usr/include
QT_INSTALL_HEADERS/raw:/usr/include
QT_INSTALL_LIBS:/home/mf/yocto-projects/qt5sdk/sysroots/aarch64-tdx-linux/usr/lib
QT_INSTALL_LIBS/raw:/usr/lib
QT_INSTALL_LIBEXECS:/home/mf/yocto-projects/qt5sdk/sysroots/aarch64-tdx-linux/usr/lib/libexec
QT_INSTALL_LIBEXECS/raw:/usr/lib/libexec
QT_INSTALL_BINS:/home/mf/yocto-projects/qt5sdk/sysroots/aarch64-tdx-linux/usr/bin
QT_INSTALL_BINS/raw:/usr/bin
QT_INSTALL_TESTS:/home/mf/yocto-projects/qt5sdk/sysroots/aarch64-tdx-linux/usr/share/tests
QT_INSTALL_TESTS/raw:/usr/share/tests
QT_INSTALL_PLUGINS:/home/mf/yocto-projects/qt5sdk/sysroots/aarch64-tdx-linux/usr/lib/plugins
QT_INSTALL_PLUGINS/raw:/usr/lib/plugins
QT_INSTALL_IMPORTS:/home/mf/yocto-projects/qt5sdk/sysroots/aarch64-tdx-linux/usr/imports
QT_INSTALL_IMPORTS/raw:/usr/imports
QT_INSTALL_QML:/home/mf/yocto-projects/qt5sdk/sysroots/aarch64-tdx-linux/usr/lib/qml
QT_INSTALL_QML/raw:/usr/lib/qml
QT_INSTALL_TRANSLATIONS:/home/mf/yocto-projects/qt5sdk/sysroots/aarch64-tdx-linux/usr/share/translations
QT_INSTALL_TRANSLATIONS/raw:/usr/share/translations
QT_INSTALL_CONFIGURATION:/home/mf/yocto-projects/qt5sdk/sysroots/aarch64-tdx-linux/etc
QT_INSTALL_CONFIGURATION/raw:/etc
QT_INSTALL_EXAMPLES:/home/mf/yocto-projects/qt5sdk/sysroots/aarch64-tdx-linux/usr/share/examples
QT_INSTALL_EXAMPLES/raw:/usr/share/examples
QT_INSTALL_DEMOS:/home/mf/yocto-projects/qt5sdk/sysroots/aarch64-tdx-linux/usr/share/examples
QT_INSTALL_DEMOS/raw:/usr/share/examples
QT_HOST_PREFIX:/home/mf/yocto-projects/qt5sdk/sysroots/x86_64-tdxsdk-linux
QT_HOST_DATA:/home/mf/yocto-projects/qt5sdk/sysroots/aarch64-tdx-linux/usr/lib
QT_HOST_BINS:/home/mf/yocto-projects/qt5sdk/sysroots/x86_64-tdxsdk-linux/usr/bin
QT_HOST_LIBS:/home/mf/yocto-projects/qt5sdk/sysroots/x86_64-tdxsdk-linux/usr/lib
QMAKE_SPEC:linux-oe-g++
QMAKE_XSPEC:linux-oe-g++
QMAKE_VERSION:3.1
QT_VERSION:5.14.2

2. qmake
Code: [Select]
mf@linux:~/yocto-projects/qt5sdk/cbindings$ qmake
Info: creating stash file /home/mf/yocto-projects/qt5sdk/cbindings/.qmake.stash
Project MESSAGE: Note: This binding version was generated for Qt 5.6.1. Current Qt is 5.14.2
Project MESSAGE: Qt documents binary compatibility in each Version Change Note: http://qt.nokia.com/developer/changes
Project MESSAGE: Adding x11extras for XOrg platform.
Project MESSAGE: Pascal Qt Interface for binding platform: BINUX
Project MESSAGE: Install location: /home/mf/yocto-projects/qt5sdk/sysroots/aarch64-tdx-linux/usr/lib

3. make
Code: [Select]
mf@linux:~/yocto-projects/qt5sdk/cbindings$ make
..
..
aarch64-tdx-linux-g++  -fstack-protector-strong  -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=... -c -pipe  -O2 -pipe -g -feliminate-unused-debug-types  --sysroot=... -Wfatal-errors -O2 -w -D_REENTRANT -fPIC -DBINUX -DQT_NO_DEBUG -DQT_PRINTSUPPORT_LIB -DQT_WIDGETS_LIB -DQT_X11EXTRAS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -I. -I../sysroots/aarch64-tdx-linux/usr/include/QtPrintSupport -I../sysroots/aarch64-tdx-linux/usr/include/QtWidgets -I../sysroots/aarch64-tdx-linux/usr/include/QtX11Extras -I../sysroots/aarch64-tdx-linux/usr/include/QtGui -I../sysroots/aarch64-tdx-linux/usr/include/QtNetwork -I../sysroots/aarch64-tdx-linux/usr/include/QtCore -Itmp -I../sysroots/aarch64-tdx-linux/usr/lib/mkspecs/linux-oe-g++ -o tmp/qdrag_c.o src/qdrag_c.cpp
aarch64-tdx-linux-g++  -fstack-protector-strong  -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=... -c -pipe  -O2 -pipe -g -feliminate-unused-debug-types  --sysroot=... -Wfatal-errors -O2 -w -D_REENTRANT -fPIC -DBINUX -DQT_NO_DEBUG -DQT_PRINTSUPPORT_LIB -DQT_WIDGETS_LIB -DQT_X11EXTRAS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -I. -I../sysroots/aarch64-tdx-linux/usr/include/QtPrintSupport -I../sysroots/aarch64-tdx-linux/usr/include/QtWidgets -I../sysroots/aarch64-tdx-linux/usr/include/QtX11Extras -I../sysroots/aarch64-tdx-linux/usr/include/QtGui -I../sysroots/aarch64-tdx-linux/usr/include/QtNetwork -I../sysroots/aarch64-tdx-linux/usr/include/QtCore -Itmp -I../sysroots/aarch64-tdx-linux/usr/lib/mkspecs/linux-oe-g++ -o tmp/qsessionmanager_c.o src/qsessionmanager_c.cpp
In file included from src/qsessionmanager_c.cpp:12:
src/qsessionmanager_c.h:24:88: error: ‘QSessionManager::RestartHint’ has not been declared
   24 | C_EXPORT void QSessionManager_setRestartHint(QSessionManagerH handle, QSessionManager::RestartHint AnonParam1);
      |                                                                                        ^~~~~~~~~~~
compilation terminated due to -Wfatal-errors.
make: *** [Makefile:41301: tmp/qsessionmanager_c.o] Error 1

zeljko

  • Hero Member
  • *****
  • Posts: 1257
    • http://wiki.lazarus.freepascal.org/User:Zeljan
Re: Yocto Recipe for libQt5Pas
« Reply #4 on: January 14, 2022, 02:48:35 pm »
But QSessionManager::RestartHint should be declared in namespace. I really don't know why it isn't.

BasePointer

  • New Member
  • *
  • Posts: 14
Re: Yocto Recipe for libQt5Pas
« Reply #5 on: January 14, 2022, 04:02:52 pm »
But QSessionManager::RestartHint should be declared in namespace. I really don't know why it isn't.

There is something here: https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/38197
But I didn't understand the solution.

BasePointer

  • New Member
  • *
  • Posts: 14
Re: Yocto Recipe for libQt5Pas
« Reply #6 on: January 14, 2022, 07:09:22 pm »
There is something here: https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/38197
But I didn't understand the solution.

Ok I understood the problem finally. Qt5 that I have was compiled with -no-sm flag which prevents QSessionManager class to be compiled.
I created qtbase_%.bbappend file to tailor packageconfig and all went good. Now I have libQt5Pas.so files in my image file and fully compatible.

qtbase_%.bbappend content:
Code: [Select]
PACKAGECONFIG += "sm"
libqt5pas.bb content:
Code: [Select]
#
# Build libQt5Pas
#

SUMMARY = "libQt5Pas for Lazarus"
SECTION = "libs"
LICENSE = "LGPLv3"
LIC_FILES_CHKSUM = "file://COPYING.TXT;md5=5d5b6fbba1566704ccfaecd6eb49518f"

PV = "1.2.9"
PR = "r0"

inherit qmake5

DEPENDS += "qtbase qtx11extras"
RDEPENDS_${PN} += "qtwayland"

S = "${WORKDIR}"

SRC_URI += "file://Qt5Pas.pro"
SRC_URI += "file://*.txt"
SRC_URI += "file://src/*.h"
SRC_URI += "file://src/*.cpp"
SRC_URI += "file://src/*.c"

Now when I run project1 on my system, no more library missing problem. But that doesn't mean it works  %)

Here is the error that I get when I run project1:
Code: [Select]
root@verdin-imx8mp-06848948:~# ./project1
[FORMS.PP] ExceptionOccurred
  Sender=EAccessViolation
  Exception=Access violation
  Stack trace:
  $0000000000581DD4  GETSYSCOLOR,  line 485 of include/winapi.inc
  $00000000006C8E88  CREATEOBJECTS,  line 2366 of qt5/qtobjects.pas
  $00000000006C88E4  CREATE,  line 2274 of qt5/qtobjects.pas
  $00000000006C48A0  QTDEFAULTCONTEXT,  line 922 of qt5/qtobjects.pas
  $00000000005FBAB8  DESTROY,  line 107 of qt5/qtobject.inc
  $00000000005FB9E4  CREATE,  line 84 of qt5/qtobject.inc
  $0000000000455044  CREATEWIDGETSET,  line 2258 of forms.pp
  $0000000000453FF4  INTERFACES_$$_init$,  line 36 of qt5/interfaces.pp
  $000000000043D048
  $0000000000423ED4  main,  line 18 of project1.lpr
  $0000FFFFBA5D9110
  $0000000000423DE8
[FORMS.PP] ExceptionOccurred

I will continue digging  :-X
« Last Edit: January 14, 2022, 11:03:36 pm by BasePointer »

BasePointer

  • New Member
  • *
  • Posts: 14
Re: Yocto Recipe for libQt5Pas
« Reply #7 on: January 14, 2022, 10:30:11 pm »
Finally it worked :)

I just needed to run it as "./project1 -platform wayland"

Code: [Select]
root@verdin-imx8mp-06848948:~# uname -a
Linux verdin-imx8mp-06848948 5.4.161-rt67-5.6.0-devel+git.0021a0c8a58f #1 SMP PREEMPT_RT Wed Jan 12 12:02:54 UTC 2022 aarch64 aarch64 aarch64 GNU/Linux
« Last Edit: January 14, 2022, 10:53:47 pm by BasePointer »

zeljko

  • Hero Member
  • *****
  • Posts: 1257
    • http://wiki.lazarus.freepascal.org/User:Zeljan
Re: Yocto Recipe for libQt5Pas
« Reply #8 on: January 15, 2022, 04:49:00 pm »
-platform xcb does not work ?

BasePointer

  • New Member
  • *
  • Posts: 14
Re: Yocto Recipe for libQt5Pas
« Reply #9 on: January 15, 2022, 06:22:30 pm »
-platform xcb does not work ?

Getting following error:
Code: [Select]
./project1 -platform xcb
MoTTY X11 proxy: Unsupported authorisation protocol
qt.qpa.xcb: could not connect to display localhost:10.0
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: minimal, offscreen, vnc, wayland-egl, wayland, webgl, xcb.

zeljko

  • Hero Member
  • *****
  • Posts: 1257
    • http://wiki.lazarus.freepascal.org/User:Zeljan
Re: Yocto Recipe for libQt5Pas
« Reply #10 on: January 15, 2022, 07:49:13 pm »
-platform xcb does not work ?

Getting following error:
Code: [Select]
./project1 -platform xcb
MoTTY X11 proxy: Unsupported authorisation protocol
qt.qpa.xcb: could not connect to display localhost:10.0
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: minimal, offscreen, vnc, wayland-egl, wayland, webgl, xcb.

Error about x11 authorization protocol is about some stalled file in $HOME afair...you should check google about it

BasePointer

  • New Member
  • *
  • Posts: 14
Re: Yocto Recipe for libQt5Pas
« Reply #11 on: January 15, 2022, 11:53:23 pm »
Error about x11 authorization protocol is about some stalled file in $HOME afair...you should check google about it

I saw some solutions on stackoverflow. But didn't try. Is there any particular reason why I should use xcb over the wayland?

zeljko

  • Hero Member
  • *****
  • Posts: 1257
    • http://wiki.lazarus.freepascal.org/User:Zeljan
Re: Yocto Recipe for libQt5Pas
« Reply #12 on: January 16, 2022, 11:23:31 am »
Error about x11 authorization protocol is about some stalled file in $HOME afair...you should check google about it

I saw some solutions on stackoverflow. But didn't try. Is there any particular reason why I should use xcb over the wayland?

Wayland is pretty unfinished yet.

BasePointer

  • New Member
  • *
  • Posts: 14
Re: Yocto Recipe for libQt5Pas
« Reply #13 on: January 17, 2022, 10:32:38 am »
Wayland is pretty unfinished yet.

Thank you I will consider that.

Once I finish my tests, I will also share final Yocto Recipe for LibQt5Pas so that all source code belong to cbindings will be pulled from gitlab and compiled automatically.
« Last Edit: January 17, 2022, 11:05:33 am by BasePointer »

BasePointer

  • New Member
  • *
  • Posts: 14
Re: Yocto Recipe for libQt5Pas
« Reply #14 on: January 17, 2022, 01:58:29 pm »
Here is the final libqt5pas.bb file. It works fine for me. I have tested it with Yocto Dunfell.

Code: Text  [Select][+][-]
  1. #
  2. # Build libQt5Pas
  3. #
  4.  
  5. SUMMARY = "libQt5Pas for Lazarus Applications"
  6. SECTION = "libs"
  7. LICENSE = "LGPLv3"
  8. LIC_FILES_CHKSUM = "file://COPYING.TXT;md5=0fb089d6440776fe0018324658b22403"
  9.  
  10. inherit qmake5
  11.  
  12.  
  13. PV = "1.2.9+git${SRCPV}"
  14. PR = "r0"
  15.  
  16. SRCREV = "d74a3b34c5b462e2e202f5fcbce130c8f1159da6"
  17. SRC_URI = "git://gitlab.com/freepascal.org/lazarus/lazarus.git;branch=main"
  18. SRC_URI[sha256sum] = "e6729420f888b24026c65cbb50aed4e72c07f8a523125eac079a1c6bafd41513"
  19.  
  20. S = "${WORKDIR}/git/lcl/interfaces/qt5/cbindings"
  21.  
  22. DEPENDS += "qtbase qtx11extras"
  23. RDEPENDS_${PN} += "qtwayland"
« Last Edit: January 17, 2022, 03:37:35 pm by BasePointer »

 

TinyPortal © 2005-2018