Lazarus

Programming => Widgetset => QT => Topic started by: Fred vS on August 15, 2011, 08:24:24 pm

Title: Error: Qt is not installed.
Post by: Fred vS on August 15, 2011, 08:24:24 pm
Hello everybody. :)
I have a free DJ application compiled with Qt.
If Qt is not installed I want that the application shows a error message like : "Error, Qt libraries are not installed, please do a sudo apt-get install Qt".
But, of course, if Qt is not installed, message dialogs do not works... :(
Anybody have a idea how to show such a message and how to know that Qt is installed ?
Thanks.
Title: Re: Error: Qt is not installed.
Post by: Blaazen on August 15, 2011, 09:08:55 pm
If you try run your Qt-application or Lazarus itself without libQt4pas.so installed, then you have this output in console:
Code: [Select]
$ ./lazarus
./lazarus: error while loading shared libraries: libQt4Pas.so.5: cannot open shared object file: No such file or directory
This is common behaviour on Linux. Linux users usually know that they have to run it from console to see what's bad.
Title: Re: Error: Qt is not installed.
Post by: Fred vS on August 15, 2011, 09:24:58 pm
Hello Mr Blaazen and thanks for your answer...
Code: [Select]
Linux users usually know that they have to run it from console to see what's bad.
Of course, but for helping Linux Dummies, is there a way to show a message dialog without Qt installed ?
Title: Re: Error: Qt is not installed.
Post by: Leledumbo on August 16, 2011, 12:04:35 am
Quote
Of course, but for helping Linux Dummies, is there a way to show a message dialog without Qt installed ?
You can try LoadLibrary-ing a Qt lib (QtCore is enough maybe?), and check the return value.
Title: Re: Error: Qt is not installed.
Post by: felipemdc on August 16, 2011, 08:57:26 am
Of course, but for helping Linux Dummies, is there a way to show a message dialog without Qt installed ?

Yes, but not using the LCL. You can use for example X11 in Linux. It is almost always installed, it could be safe. Your code could be something like this:

<delphi>
program blabla;
....
begin
  lLib := LoadLibrary(...);
  if lLib = nil then
  begin
    ShowX11MessageBox;
  end;
end.
</delphi>

And you can implement the message box using X11. A initial code to get started: http://wiki.lazarus.freepascal.org/X11#A_window_with_a_message

In Windows you can use the Windows API. There is a API for showing message boxes, so it should be much easier.
Title: Re: Error: Qt is not installed.
Post by: Fred vS on August 16, 2011, 10:32:20 pm
@ Mr Blaazen, Leledumbo and Felipemdc
Thank you, gracias, obrigado...
I gonna test it... ;D
Title: Re: Error: Qt is not installed.
Post by: felipemdc on August 17, 2011, 08:57:40 am
Another thing to notice. I think that this might be impossible, because afaik the link to libQt4Pas.so is static so the error message is from the operating system and your program doesn't even start executing. In that case it will be impossible to change how the operating system handles this kind of error.
Title: Re: Error: Qt is not installed.
Post by: BigChimp on August 17, 2011, 09:46:49 am
Seems like a better idea is to use the distribution's packaging system and create .deb/.rpm/etc files where the Qt dependency is included.

Or create a launcher app that checks for qt and runs the main app if present.
Title: Re: Error: Qt is not installed.
Post by: Fred vS on August 17, 2011, 11:27:20 pm
@ BigChimp

Quote
Or create a launcher app that checks for qt

Ok, and how to do it  :-[

Thanks
Title: Re: Error: Qt is not installed.
Post by: BigChimp on August 20, 2011, 12:06:34 pm
@ BigChimp

Quote
Or create a launcher app that checks for qt

Ok, and how to do it  :-[

Thanks
I'd have a look at Leledumbo's & Felipe's posts: write an FPC program that uses LoadLibrary to load a core QT library. If that fails, show a message box using X11 code on Linux (or Win32 API or OSX Carbon/Cocoa...).
If it works, execute the main Qt program (using TProcess or whatever)...

Regards,
BigChimp
Title: Re: Error: Qt is not installed.
Post by: DenJean on August 24, 2011, 10:35:25 am
Let your user start the program by a script, the script calls the actual program if Qt is available and otherwise use the many ways available to send a system message. So check existence of the message program, if it fails try the next one.

notify-send -t 0 "Testing" "Hello there"
xmessage -button ok -center file - "Hello"
shutdown -k -t 0 now "Hello"
TinyPortal © 2005-2018