Recent

Author Topic: libqt5pas1 as a dependency of a SO file  (Read 4636 times)

Graham1

  • New Member
  • *
  • Posts: 27
libqt5pas1 as a dependency of a SO file
« on: July 26, 2021, 05:29:07 am »
There is a program written in Python that uses Qt5, not written by me. I have written Lazarus libraries (as .SO files) that interface with this program, but my libraries require some configuration details so I use a form for this. I found I had to compile my libraries using Qt5 rather than Gtk2 as the main program wouldn't load them otherwise. I suppose because an SO/Application's forms are really part of the calling program they were conflicting in some way when mine were Gtk2 and his were Qt5.

Anyway, everything is working really well with one annoyance. When he distributes his program with my libraries, they fail to load if the end user doesn't have libqt5pas1 installed. He's put a TRY...EXCEPT.. piece of code around the dynamic loading of my libraries with a screen to tell the user to run one of:

sudo apt install libqt5pas1
sudo dnf install qt5pas

but is there some neater way to handle this? As a long time Windows user and a total newcomer to Linux it seems odd to me that a user should be expected to go into a Console screen and run an install command. Or is this normal for Linux and something users expect to do?

I think from other threads on this forum that trying to build the libqt5pas file(s) into my libraries is a worse option that just asking a user to install it themselves but maybe I'm missing something. Can I put something in my library project that would handle this better? At the moment  the Project Inspector shows my files and in Required Packages has only "LCL". I can't see anything in the Project Options to define what dependencies a project has.

Thanks!

Windows 10 Home 64-bit
Lazarus 2.0.12 / FPC 3.2.0

lucamar

  • Hero Member
  • *****
  • Posts: 4219
Re: libqt5pas1 as a dependency of a SO file
« Reply #1 on: July 26, 2021, 10:06:52 am »
A better solution, IMO, would be to install the whole application (including your library) as a .deb (or .rpm, or whatever) package and either add libqt5pas as a requirement for it (the .deb) or include it too inside the package.

Note also that a normal user should be able to install libqt5pas by itself by using whatever package manager he uses normally (e.g. Synaptic); there's no need to go down to a console and use Apt, despite that being the most frequent advice one finds when people ask "how to install X".
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

PascalDragon

  • Hero Member
  • *****
  • Posts: 3335
  • Compiler Developer
Re: libqt5pas1 as a dependency of a SO file
« Reply #2 on: July 26, 2021, 01:17:03 pm »
but is there some neater way to handle this? As a long time Windows user and a total newcomer to Linux it seems odd to me that a user should be expected to go into a Console screen and run an install command. Or is this normal for Linux and something users expect to do?

It is expected that an application provides a Readme or Install file in its distribution where it lists required libraries so that a user can install them by themselves.

If a package for a distribution exists then such a package will have the required libraries listed as requirements and the package installer will do it automatically (as lucamar explained).

Alternatively there are so called AppImage images where everything an application requires is contained in (though you need to prepare them accordingly).

dbannon

  • Hero Member
  • *****
  • Posts: 1541
    • tomboy-ng, a rewrite of the classic Tomboy
Re: libqt5pas1 as a dependency of a SO file
« Reply #3 on: July 26, 2021, 01:18:39 pm »
A better solution, IMO, would be to install the whole application (including your library) as a .deb (or .rpm, or whatever) package and either add libqt5pas as a requirement for it (the .deb) or include it too inside the package.
Indeed, thats the only real solution. However, building a deb is no easy task for a beginner.

Quote
Note also that a normal user should be able to install libqt5pas by itself by using whatever package manager he uses normally (e.g. Synaptic); there's no need to go down to a console and use Apt, despite that being the most frequent advice one finds when people ask "how to install X".
Probably the main reason that the advice is usually "sudo apt install something" is that its far easier to type those 30 or so characters that describe, in words, how to bring up the GUI and what to click. And some distros don't have Synaptic installed (@##!).  So, to address the OP's implied question, yep, most Linux users are pretty comfortable dropping back to the command line for things like that. Indeed, many prefer the command line for things like that. Perhaps, depending on the intended market, that solution mentioned in the first post is not that bad really.

But a well made deb would install both the python and pascal components, all necessary dependencies, menu items and icons etc. And easily converted to an RPM if necessary. But it too would need to be installed. I'd suggest "sudo apt install somepackage.....".

Davo





Lazarus 2, Linux (and reluctantly Win10, OSX)
My Project - https://github.com/tomboy-notes/tomboy-ng

Graham1

  • New Member
  • *
  • Posts: 27
Re: libqt5pas1 as a dependency of a SO file
« Reply #4 on: July 27, 2021, 12:03:43 am »
Probably the main reason that the advice is usually "sudo apt install something" is that its far easier to type those 30 or so characters that describe, in words, how to bring up the GUI and what to click.

I think that really is the main reason!

The program and my libraries are currently being distributed using a makeself archive (https://github.com/megastep/makeself) so is installed using the command:

Code: Bash  [Select][+][-]
  1. sh ./programname.sh

I have tried including the files:

libQt5Pas.so
libQt5Pas.so.1
libQt5Pas.so.1.2
libQt5Pas.so.1.2.6

in his programname/bin folder but that doesn't seem to be sufficient.

It looks like we might have to learn about deb/rpm packaging. Is there a good, step-by-step beginners guide to this?!

Thanks everyone for your feedback.
Windows 10 Home 64-bit
Lazarus 2.0.12 / FPC 3.2.0

dbannon

  • Hero Member
  • *****
  • Posts: 1541
    • tomboy-ng, a rewrite of the classic Tomboy
Re: libqt5pas1 as a dependency of a SO file
« Reply #5 on: July 27, 2021, 03:01:01 am »
....
I have tried including the files:

libQt5Pas.so
libQt5Pas.so.1
libQt5Pas.so.1.2
libQt5Pas.so.1.2.6


No, that will not work Graham, Linux and Unix puts a lot of effort into managing shared libraries, there are predefined places where libraries end up and apps do not look elsewhere for them. There are ways around that but they attack the very meaning of Unix.

If you have a script that is doing your install, you can include a line in that script that does an "official" install, "sudo apt install libqt5pas", the person running the install will be asked to put in their password and it will work.  However, as I mentioned above, Linux users are generally quite happy to run that command themselves. In fact, sensible one will feel a lot safer, there is a risk associated with responding to an unknown script that asks for your password.  You feel a lot safer issuing a specific command that you know will ask for your password.

My suggestion is you have the end user run your install script and at the end of it, you have a line along the lines of

Code: [Select]
echo "OK, app is installed, now you must type in and run the following command (you will be asked for root password) "
echo "    sudo  apt install libqt5pas [enter]"

That approach gives you a chance to test to see if qt5pas is already installed, and to see which flavour of linux it is so you can adjust the command line, different Linuxes use different installers AND even different names for the library.

There a number of different tutorials about how to make a deb, but none are really suitable for beginners.

There are two basic sorts, a binary deb and a source deb. If you want to distribute the app via the various Linux Repos,it has to be a src deb and thats massively hard.  But a binary deb is much easier, especially if you are happy to ignore some of the warnings that will almost certainly be generated.

The idea is to build a directory that has files located in equivalent to the final places they need end up in. Then run tool that bundles it up into a deb, you need to conform to the rules about where things go but not absolutely. Everything is installed in root space, nothing in user space.  So, you build that directory, somewhere down in your own space and the tool looks at it, bundles things up, and finally creates the deb file.

There is also a 'control' file that specifies meta data about the package, things like dependencies (ie libqt5pas) and where you want menu entries to appear etc.

I build both binary packages and src packages for my app, please look at https://github.com/tomboy-notes/tomboy-ng/blob/master/package/package.bash, particularly, the function, DebianPackage ()  for an example of how to build a binary package. The script is quite long because it does a whole lot of other packaging things as well.

Davo

Lazarus 2, Linux (and reluctantly Win10, OSX)
My Project - https://github.com/tomboy-notes/tomboy-ng

 

TinyPortal © 2005-2018