Recent

Author Topic: Compiling Qt6 project on Linux Mint 20 (Ubuntu 20.04)  (Read 2221 times)

Graham1

  • Jr. Member
  • **
  • Posts: 72
Compiling Qt6 project on Linux Mint 20 (Ubuntu 20.04)
« on: October 01, 2025, 06:24:22 am »
I create binaries of SO files that are distributed by somebody else with his program, and I compile them on Mint 20 as I want to keep to an older Glibc version. It works fine with Qt5, but he says he is moving to Qt6. (Yes, my SO does have its own screens and needs to use Qt5/Qt6 but that's a different conversation). It didn't seem possible to compile with Qt6 on Mint 20 until I saw this on David Bannon's Github page:

Code: Text  [Select][+][-]
  1. I now build these libraries (for x86-64) on a U20.04 VM to ensure backwards compatibility with glibc. However, U20.04 does not have a suitable Qt6, so, get one from this PPA - http://ppa.launchpad.net/okirby/qt6-backports/ubuntu - a file called /etc/apt/sources.list.d/okirby-ubuntu-qt6-backports-focal.list must contain the following -
  2. deb http://ppa.launchpad.net/okirby/qt6-backports/ubuntu focal main
  3.  

It seems he does exactly what I want and that it IS possible. But I've been using DOS/Windows for 50 years and Linux drives me up the wall. I can't even tell which file I need to download let alone what I then do with it! Is there anywhere I can get simple (really simple!) step-by-step instructions of how to install this Qt6 version in Mint 20? Like David I'm running Mint in a VM.

Thank you!
Windows 10/11 Home 64-bit (and Linux because I have to)
Lazarus 2.0.12 / FPC 3.2.0 (because libQt5pas 1.2.6)
Linux Mint 20 (because GLIBC_2.31)

dbannon

  • Hero Member
  • *****
  • Posts: 3678
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Compiling Qt6 project on Linux Mint 20 (Ubuntu 20.04)
« Reply #1 on: October 01, 2025, 02:36:58 pm »
Hi Graham, the issue is that Ubuntu 20.04 did not have a Qt6 release as, I think you understand.  But there was nothing inherently wrong with building a Qt6 'bundle' on a U20.04 machine, you could, if you have sufficient patience, do so your self.

But  Naomi Kirby has done the hard work for us and put the result at  https://launchpad.net/~okirby/+archive/ubuntu/qt6-backports

From memory, its based on one minor release earlier than the one Lazarus Qt6 needs but my experience found it works fine (Qt6 6.2.2 v 6.2.3). As well as the Qt6 libraries themselves, I also build the Qt6 version of my app, tomboy-ng the same way. No complaints !

That link above shows you how to edit your /etc/source.list so that the apt command looks at Naomi's repo so, make that edit, do "apt update" then try to install the libqt6pas library (or other package that needs Qt6).

Good luck !

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

Graham1

  • Jr. Member
  • **
  • Posts: 72
Re: Compiling Qt6 project on Linux Mint 20 (Ubuntu 20.04)
« Reply #2 on: October 02, 2025, 05:57:09 am »
Hi David, it works! Thank you so much. Mint doesn't actually use the version of source.lists in /etc/apt which I found out from running

Code: Text  [Select][+][-]
  1. inxi -Sr

but that's OK as Naomi's commands added it correctly. For anybody else doing this, you need to run:

Code: Text  [Select][+][-]
  1. sudo add-apt-repository ppa:okirby/qt6-backports
  2. sudo apt update
  3. sudo apt install qt6-base-dev

Then copy David's libqt6pas.so file into /lib/x86_64-linux-gnu/ (opened as Root to allow this) and then used Edit > Make Link and Right click > Rename to create two link files to David's file called:
    libQt6Pas.so.6
    libQt6Pas.so

For Linux 20/Ubuntu 20 you also need to be using Lazarus Project 3.x as version 2.x doesn't give you the option to select Qt6 as the LCLWidgetType and (at least, on my machine) version 4.x doesn't seem to run at all.
Windows 10/11 Home 64-bit (and Linux because I have to)
Lazarus 2.0.12 / FPC 3.2.0 (because libQt5pas 1.2.6)
Linux Mint 20 (because GLIBC_2.31)

dbannon

  • Hero Member
  • *****
  • Posts: 3678
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Compiling Qt6 project on Linux Mint 20 (Ubuntu 20.04)
« Reply #3 on: October 02, 2025, 07:12:18 am »
......
Then copy David's libqt6pas.so file into /lib/x86_64-linux-gnu/ (opened as Root to allow this) and then used Edit > Make Link and Right click > Rename to create two link files to David's file called:
    libQt6Pas.so.6
    libQt6Pas.so

OK, two issues that disturb me. After you installed qt6-base-dev you should not have needed to do any more. It should have brought along  libQt6Pas.so.6 and libQt6Pas.so, which in turn would get all the rest of the (none pascal) qt6 libraries.  Did you have both the libqt6pas-dev and libqt6pas-6 (from my repo) already downloaded ? if so, I need to look at my package specs ....

Quote
For Linux 20/Ubuntu 20 you also need to be using Lazarus Project 3.x as version 2.x doesn't give you the option to select Qt6 as the LCLWidgetType and (at least, on my machine) version 4.x doesn't seem to run at all.

Yeah,makes sense, its quite likely Lazarus 2 did not support Qt6 but its also possible that you were installing the Mint (ie Ubuntu, ie Debian) Lazarus package which supports only the default gtk2. The Qt5 parts are an addition package install. Maybe Qt6 too ? Anyway, not recommended.

Again, depending on where the lazarus you installed comes from, with Lazarus 4.2 (which you should be using) may or may not include the Lazarus Qt6 support. If its a debian package probably not unless you got one of the experimental ones. If you got the package from the official Lazarus repo at SourceForge, it should and almost certainly does work with Qt6. If you are smart and build from source (don't install, leave it in your home directory and run from there) Qt6 is absolutely available.

So, please help to clarify both the above, bug reports are always welcome !

Davo

Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

Graham1

  • Jr. Member
  • **
  • Posts: 72
Re: Compiling Qt6 project on Linux Mint 20 (Ubuntu 20.04)
« Reply #4 on: October 02, 2025, 10:21:10 am »
Hi David, I hope the following answers your questions.

As a test I created a new VM with Mint 20.3 and run the updates to make sure it was up to date. After rebooting I then ran

Code: Text  [Select][+][-]
  1. sudo apt update
  2. sudo apt install build-essential
  3. sudo apt install ./fpc-laz_3.2.2-210709_amd64.deb
  4. sudo apt install ./fpc-src_3.2.2-210709_amd64.deb
  5. sudo apt install ./lazarus-project_4.2.0-0_amd64.deb

But startlazarus showed a Glibc 2.34 error. So:

Code: Text  [Select][+][-]
  1. sudo apt remove laz*

Then I downloaded the Lazarus source file and used make bigide. Then 4.2 ran OK. Changing the opening default project to LCLWidgetType Qt6 and compiling failed with a missing -lQt6pas, of course. So I ran:

Code: Text  [Select][+][-]
  1. sudo add-apt-repository ppa:okirby/qt6-backports
  2. sudo apt update
  3. sudo apt install qt6-base-dev

Again trying to compile failed, missing Qt6pas. I searched the file system for libQt6pas and it didn't find it anywhere. So I downloaded the deb files from your Github page and ran:

Code: Text  [Select][+][-]
  1. sudo apt install ./libqt6pas6_6.2.10-1_amd64.deb
  2. sudo apt install ./libqt6pas6-dev_6.2.10-1_amd64.deb

Now compiling the project with Qt6 worked successfully. I realised my error before was trying to install just the pas6-dev file without installing the pas6 file first (just like I would install only libQt5pas-dev before). It doesn't like that:

Code: Text  [Select][+][-]
  1. graham@graham-L20Test:~/Downloads$ sudo apt install ./libqt6pas6-dev_6.2.10-1_amd64.deb
  2. Reading package lists... Done
  3. Building dependency tree      
  4. Reading state information... Done
  5. Note, selecting 'libqt6pas6-dev' instead of './libqt6pas6-dev_6.2.10-1_amd64.deb'
  6. Some packages could not be installed. This may mean that you have
  7. requested an impossible situation or if you are using the unstable
  8. distribution that some required packages have not yet been created
  9. or been moved out of Incoming.
  10. The following information may help to resolve the situation:
  11.  
  12. The following packages have unmet dependencies:
  13.  libqt6pas6-dev : Depends: libqt6pas6 (>= 2.10) but it is not installable
  14. E: Unable to correct problems, you have held broken packages.

Let me know if you need any more info! Thanks.
Windows 10/11 Home 64-bit (and Linux because I have to)
Lazarus 2.0.12 / FPC 3.2.0 (because libQt5pas 1.2.6)
Linux Mint 20 (because GLIBC_2.31)

Graham1

  • Jr. Member
  • **
  • Posts: 72
Re: Compiling Qt6 project on Linux Mint 20 (Ubuntu 20.04)
« Reply #5 on: October 02, 2025, 11:49:58 am »
I thought it was going too well....!

Now if I start a new Application project, set its LCLWidgetType to Qt5 and compile it I get errors:

Code: Text  [Select][+][-]
  1. Compile Project, Target: /home/graham/tmp/project1: Exit code 1, Errors: 5, Warnings: 4
  2. Warning: linker: /usr/bin/ld: /home/graham/Lazarus/lcl/units/x86_64-linux/qt5/qtint.o: in function `CREATE':
  3. qtobject.inc(54,0) Error: linker: undefined reference to `QGuiApplication_setFallbackSessionManagementEnabled'
  4. Warning: linker: /usr/bin/ld: /home/graham/Lazarus/lcl/units/x86_64-linux/qt5/qtint.o: in function `SETACTIVEWINDOW':
  5. qtwinapi.inc(5846,0) Error: linker: undefined reference to `QGuiApplication_applicationState'
  6. Warning: linker: /usr/bin/ld: /home/graham/Lazarus/lcl/units/x86_64-linux/qt5/qtint.o: in function `SETFOREGROUNDWINDOW':
  7. qtwinapi.inc(6049,0) Error: linker: undefined reference to `QGuiApplication_applicationState'
  8. Warning: linker: /usr/bin/ld: /home/graham/Lazarus/lcl/units/x86_64-linux/qt5/qtobjects.o: in function `ENDX11SELECTIONLOCK':
  9. qtobjects.pas(3906,0) Error: linker: undefined reference to `QTimer_singleShot3'
  10. project1.lpr(28,1) Error: Error while linking

Any idea what I've done wrong? The Qt6 version of this compiles fine. This is running Lazarus 4.2 from a folder Lazarus in my Home folder. I have installed libqt5pas-dev as normal.
Windows 10/11 Home 64-bit (and Linux because I have to)
Lazarus 2.0.12 / FPC 3.2.0 (because libQt5pas 1.2.6)
Linux Mint 20 (because GLIBC_2.31)

dbannon

  • Hero Member
  • *****
  • Posts: 3678
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Compiling Qt6 project on Linux Mint 20 (Ubuntu 20.04)
« Reply #6 on: October 02, 2025, 02:28:59 pm »
....
Now compiling the project with Qt6 worked successfully. I realised my error before was trying to install just the pas6-dev file without installing the pas6 file first (just like I would install only libQt5pas-dev before). It doesn't like that:
OK, that sounds like I have messed up somewhere. The -dev package should depend on the main lbqt6pas package. I'll have to have a good look at that. I guess I usually mention both on the same install line and have not tested it properly.

Now, WRT your Qt5 problem. Where have the libqt6Pas packages come from ?  Again if you are using the ones shipped with U20.04, they will be too old to work with Lazarus 4.2.  If they are from my repo, that is more of a worry !

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

Graham1

  • Jr. Member
  • **
  • Posts: 72
Re: Compiling Qt6 project on Linux Mint 20 (Ubuntu 20.04)
« Reply #7 on: October 02, 2025, 10:48:51 pm »
OK, that sounds like I have messed up somewhere. The -dev package should depend on the main lbqt6pas package. I'll have to have a good look at that. I guess I usually mention both on the same install line and have not tested it properly.

No, I think you have it correct. If I install your libqt6pas file first I can then install the -dev version too. Originally I thought it was one or the other depending on whether I wanted runtime support only or (runtime and) dev options too.

Now, WRT your Qt5 problem. Where have the libqt6Pas packages come from ?  Again if you are using the ones shipped with U20.04, they will be too old to work with Lazarus 4.2.  If they are from my repo, that is more of a worry !

I think you meant libQt5pas here? I just installed them using sudo apt install libqt5pas-dev so they would be the versions from U20.04. So if I want maximum portability without providing links to your site, as well as using Mint/Ubuntu 20 I should stick to my VM with the old Lazarus 2.0.12 for Qt5.

I wish the Lazarus Project options Compile screen just had the choices (regardless of the Lazarus Project and Ubuntu versions):

Code: Text  [Select][+][-]
  1. Make compatible with:
  2.     [x] Glibc_2.31  [ ] Glibc_2.34  [ ] ....
  3.     [x] libQt5pas 1.2.6  [ ] libQt5pas 1.2.8 .....
  4.     [ ] libQt6pas ....

I suppose it all relies on too many system files for that to be possible though.

Windows 10/11 Home 64-bit (and Linux because I have to)
Lazarus 2.0.12 / FPC 3.2.0 (because libQt5pas 1.2.6)
Linux Mint 20 (because GLIBC_2.31)

dbannon

  • Hero Member
  • *****
  • Posts: 3678
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Compiling Qt6 project on Linux Mint 20 (Ubuntu 20.04)
« Reply #8 on: October 03, 2025, 02:55:33 am »
....If I install your libqt6pas file first I can then install the -dev version too.
No, you should not be able to install the -dev package unless the main package is either already installed or you have both mentioned on the command line. The fact that the -dev package installed for you before the main package was considered is an error. Indeed, I don't know what it did, all the -dev package does is make a simlink to the main library (and a couple of doc files). If the main package is not there, did it make a bad link ?  Thats my problem to solve ! 

Quote
I just installed them using sudo apt install libqt5pas-dev so they would be the versions from U20.04. So if I want maximum portability without providing links to your site, as well as using Mint/Ubuntu 20 I should stick to my VM with the old Lazarus 2.0.12 for Qt5.

Yes, you can do that. However, much of the improvements provided by later versions of Lazarus Qt5 fixed important bugs (in Lazarus Qt5 AND the main QT5 libraries too) so, please test very carefully before shipping any product based on Qt5 and Lazarus 2.  I tell my users to first install the necessary "third party" libraries. I am afraid that comes with using old versions of Linux.

Quote
I wish the Lazarus Project options Compile screen just had the choices (regardless of the Lazarus Project and Ubuntu versions):

Code: Text  [Select][+][-]
  1. Make compatible with:
  2.     [x] Glibc_2.31  [ ] Glibc_2.34  [ ] ....
  3.     [x] libQt5pas 1.2.6  [ ] libQt5pas 1.2.8 .....
  4.     [ ] libQt6pas ....

I suppose it all relies on too many system files for that to be possible though.

Yes, I agree its less than desirable !  With the GLib issue Its the same with other development platforms and, apparently, no one else has come up with a better solution. A small team here tried very hard to find a general solution but it seemed too complicated to me, search the forum.  With Qt5 and Qt6, its really just the steady development of Qt5 and Qt6 themselves, early releases are unstable, Zelko waits until a "long term" release of Qt5 or Qt6 appears and then bases his Lazarus interface on that. But in the meantime he has test versions out and the distros pick those up and ship them !

Gtk2 is now, finally frozen and hardly changes but GTK2 is, in my opinion, past its use by date. Sig ....

Anyway, please do test your product before shipping, very carefully !

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

Graham1

  • Jr. Member
  • **
  • Posts: 72
Re: Compiling Qt6 project on Linux Mint 20 (Ubuntu 20.04)
« Reply #9 on: October 03, 2025, 04:18:13 am »
No, you're misunderstanding what I said! The commands I ran were:

Code: Text  [Select][+][-]
  1. sudo apt install ./libqt6pas6_6.2.10-1_amd64.deb
  2. sudo apt install ./libqt6pas6-dev_6.2.10-1_amd64.deb

And that worked fine. Originally I only tried the second line, the dev install, and that failed just as you said it should. Your files work exactly as you expected them too, it was me that got it wrong.

My Lazarus 2/Qt5 program has been OK since Lazarus 2 was current so I think I'm OK. The form, although necessary, doesn't need to do anything too clever - just one form with a few tabs and some basic graphics so maybe I got lucky.
Windows 10/11 Home 64-bit (and Linux because I have to)
Lazarus 2.0.12 / FPC 3.2.0 (because libQt5pas 1.2.6)
Linux Mint 20 (because GLIBC_2.31)

dbannon

  • Hero Member
  • *****
  • Posts: 3678
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Compiling Qt6 project on Linux Mint 20 (Ubuntu 20.04)
« Reply #10 on: October 03, 2025, 06:30:56 am »
Oh, excellent ! Yep, I thought you meant the -dev version installed without the main one. Thanks for clarifying. Hope it all works out.

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

 

TinyPortal © 2005-2018