Project

General

Profile

Support #1393

GUI with Qt5

Added by John Abbott over 4 years ago. Updated over 1 year ago.

Status:
Feedback
Priority:
Normal
Category:
GUI
Target version:
Start date:
13 Jan 2020
Due date:
% Done:

90%

Estimated time:
Spent time:

Description

Ulrich von der Ohe has written saying that he appears to have a working GUI with Qt5 (on his Linux box).

He has sent me patches. I plan to look at them when I'm in Genoa (feb 2020).

CoCoALib-0.99718_patch_stdthread (24.6 KB) CoCoALib-0.99718_patch_stdthread Ulrich von der Ohe, 03 Mar 2022 20:40
CoCoALib-0.99800_gui.sh (12.4 KB) CoCoALib-0.99800_gui.sh Ulrich von der Ohe, 07 Apr 2022 03:53
qt5check.sh (585 Bytes) qt5check.sh Ulrich von der Ohe, 07 Oct 2022 15:25
qt5check.pro (130 Bytes) qt5check.pro Ulrich von der Ohe, 07 Oct 2022 15:25
qt5check.cpp (195 Bytes) qt5check.cpp Ulrich von der Ohe, 07 Oct 2022 15:26
qt5check.sh (447 Bytes) qt5check.sh Ulrich von der Ohe, 07 Oct 2022 19:47
qt5-check.sh (2.33 KB) qt5-check.sh Ulrich von der Ohe, 11 Oct 2022 17:58
buildscriptpatches (25.7 KB) buildscriptpatches Ulrich von der Ohe, 24 Oct 2022 08:54
CoCoALib-0.99800_qt5gui+buildscriptpatches.sh (39.2 KB) CoCoALib-0.99800_qt5gui+buildscriptpatches.sh Ulrich von der Ohe, 24 Oct 2022 08:54
CoCoALib-0.99800_patches_2022-11-20.sh (41.3 KB) CoCoALib-0.99800_patches_2022-11-20.sh Ulrich von der Ohe, 20 Nov 2022 14:52

Related issues

Related to CoCoA-5 - Bug #1093: GUI: bugs and slugsIn Progress2017-07-23

Related to CoCoA-5 - Support #1387: John's visit Feb 2020Closed2020-01-07

Related to CoCoA-5 - Support #240: GUI compilation: GMP is not naturally thread-safeClosed2012-09-27

Related to CoCoALib - Support #613: Which ubuntu / debian packages are needed to compile CoCoAClosed2014-09-03

Related to CoCoALib - Bug #1662: txt2tags: problem with filenames containing "_" or "-"Resolved2022-02-11

Related to CoCoALib - Design #1699: Shell scripts: Shebang line, etcIn Progress2022-10-11

History

#1 Updated by John Abbott over 4 years ago

  • Related to Bug #1093: GUI: bugs and slugs added

#2 Updated by John Abbott over 4 years ago

#3 Updated by John Abbott about 4 years ago

  • Related to Support #240: GUI compilation: GMP is not naturally thread-safe added

#4 Updated by John Abbott about 4 years ago

  • Target version changed from CoCoA-5.3.0 to CoCoA-5.4.0

There was not enough time during my visit, so we were unable to look at this. Postponing to next version.

#5 Updated by John Abbott over 3 years ago

  • Related to Support #613: Which ubuntu / debian packages are needed to compile CoCoA added

#6 Updated by John Abbott about 2 years ago

  • Target version changed from CoCoA-5.4.0 to CoCoA-5.4.2

I do not want to lose this, but there is never time... grrr!

#7 Updated by John Abbott about 2 years ago

  • Status changed from New to Resolved
  • Assignee set to Ulrich von der Ohe
  • % Done changed from 0 to 80

I have tried Ulrich's patches and it works!

I did also try switching to std::thread etc. Everything compiled, but C5 would crash instantly.
No idea why, and I don't want to investigate.

Anyway, many thanks to Ulrich! He should register here how much time he spent revitalizing the code.

#8 Updated by Ulrich von der Ohe about 2 years ago

John Abbott wrote:

I did also try switching to std::thread etc. Everything compiled, but C5 would crash instantly.
No idea why, and I don't want to investigate.

I am attaching a patch with which the GUI works (here...) using std::thread instead of boost::thread.
The crucial part is a call to std::thread::detach(), which is apparently not necessary in the boost version.

Installation of the patch is possible by executing patch -p1 < ../CoCoALib-0.99718_patch_stdthread inside the (Qt5 patched) CoCoALib 0.99718 directory.

#9 Updated by John Abbott about 2 years ago

It works for me too :-)

I'll clean up, and check into CVS.

Thanks to Ulrich!

#10 Updated by John Abbott about 2 years ago

Why does the code compile without #include <thread>? (in file C5.H)

#11 Updated by John Abbott about 2 years ago

  • Status changed from Resolved to Feedback
  • % Done changed from 80 to 90

I have checked in. Also improved configure (to be more helpful).
Modified some code to eliminate compiler warnings (and asked Bruns to do so too).

Thanks to Ulrich, again!

#12 Updated by Ulrich von der Ohe about 2 years ago

John Abbott wrote:

Why does the code compile without #include <thread>? (in file C5.H)

In case the question is still open: There is a chain of #includes as follows:

"C5.H"  >  "Interpreter.H"  >  <boost/asio.hpp>  >  ...  >  <thread>.

I am not sure if the "..." exists on every system, but there is such a chain on mine. In any case, it seems a good idea to #include <thread> in C5.H directly.

By the way, a possible cleaner solution than what I proposed earlier (calling std::thread::detach() in C5.C) would be to save the thread in a (new) member variable intThread in Console (which may be private). The call to std::thread::detach() can then be avoided since intThread never goes out of scope (while the Console object lives). On the other hand it works just fine as it is now and all else being equal it is only a question of aesthetics.

#13 Updated by Ulrich von der Ohe about 2 years ago

It seems that many of the files needed to build the GUI are missing from the CoCoALib 0.99800 release (build system files as well as source files which had all been present in 0.99718).

Therefore the GUI cannot be built from the files provided in CoCoALib 0.99800.

Since many other GUI files still remain in the release and are in fact patched this doesn't seem like it was intended.

#14 Updated by John Abbott about 2 years ago

  • Related to Bug #1662: txt2tags: problem with filenames containing "_" or "-" added

#15 Updated by Ulrich von der Ohe about 2 years ago

Ulrich von der Ohe wrote:

It seems that many of the files needed to build the GUI are missing from the CoCoALib 0.99800 release (build system files as well as source files which had all been present in 0.99718).

Therefore the GUI cannot be built from the files provided in CoCoALib 0.99800.

Since many other GUI files still remain in the release and are in fact patched this doesn't seem like it was intended.

For the time being, perhaps the attached shell script is useful. It produces a version of CoCoALib 0.99800 with GUI related files copied over (and patched for Qt5) from 0.99718 from which the Qt5 GUI can be built. See the comment at the beginning of the script for instructions.

#16 Updated by John Abbott about 2 years ago

I have now modified release-source.sh so that it copies also the GUI stuff.
Checked in. We still need to sort out copyright!

#17 Updated by John Abbott about 2 years ago

I am not entirely sure about the legal situation if we distribute the GUI
code which has licence GPLv3 along with code with a different licence
(e.g. our default is GPLv3+). No doubt we could ask Lagorio to transfer
copyright to us (so we can modify the licence), but the QcodeEdit code
was written by an unknown (namely fullmetalcoder).

I have modified release-source so that it produces a warning if the
licence is not GPLv3(+) and if someone tries to include the GUI sources.

#18 Updated by John Abbott over 1 year ago

I am tempted to release the code as-is.
The copyright question is important only if we want to make a non GPL release;
and my release script already warns about that.

It would be good to close this issue.

#19 Updated by Ulrich von der Ohe over 1 year ago

As far as I can tell, potential future licensing issues w.r.t. QCodeEdit are independent of the move to Qt5. Hence it makes sense to discuss them separately from this issue, when necessary.

I agree that this can be released and the issue closed. (It seems I don't have permission to close it.)

#20 Updated by John Abbott over 1 year ago

Ulrich, a question for you:
Would it be easy to make a very simple test program for Qt which could be used
by a script which checks that qmake and the relevant libraries are installed?
If so, are you willing and able to write such an example?
[I'm hoping it would be no more than 10 lines total]

As an example of a script, you can look at configuration/gmp-check-cxxflags.sh
If you can write the C++ program, I can wrap it into a script (I hope).

#21 Updated by Ulrich von der Ohe over 1 year ago

Hi John, I attach three files which I think should do the job:

1) qt5check.sh: Checks for qmake, runs it it on qt5check.pro, makes the resulting makefile, and runs the resulting program.
2) qt5check.pro: A qmake project file that depends on the same Qt5 libraries as the CoCoA GUI.
3) qt5check.cpp: A C++ program that prints the Qt5 version number.

The actual check for the libraries is done via qmake and the project file, and we also compile and run a program that uses a Qt5 library function.

Please let me know if this is okay for you (or modify as you wish).

#22 Updated by John Abbott over 1 year ago

Thank Ulrich! That was quick.
I shall try to incorporate your test ASAP.
Right now I do not have access to CVS -- VPN problems with Ubuntu 22.04; hope they'll be solved next week.

#23 Updated by Ulrich von der Ohe over 1 year ago

I attach a new version of qt5check.sh. Please use this one instead of the one I uploaded earlier.

For macOS, the qmake options set in src/CoCoA-5/make-c5makefile.sh are more involved than I initially thought and the previous qt5check.sh did not set them correctly (but made the impression to do so).

The new qt5check.sh does NOT attempt to treat macOS differently from other systems, and I presume that this is okay for a simple test whether the libraries exist.

It would be good if someone running macOS could confirm that the script succeeds (with relevant parts of Qt5 installed).

The code in make-c5makefile.sh seems to laboriously determine the architecture of the system (e.g. x86_64) (couldn't one use uname -m for that?) and then to force qmake to build for that architecture.

It might be that the macOS specific stuff in make-c5makefile.sh has by now become obsolete. In this case it would be better to remove it in make-c5makefile.sh than to also clutter qt5check.sh with it.

#24 Updated by Ulrich von der Ohe over 1 year ago

I am not convinced the macOS specific stuff in make-c5makefile.sh is still useful. I certainly have not altered it for the Qt5 version.

By the way, I don't know if the GUI works on macOS.

#25 Updated by Ulrich von der Ohe over 1 year ago

I attach a revised version of the shell script. It is somewhat modeled after configuration/gmp-check-cxxflags.sh (as you suggested). The .pro and .cpp files are not necessary anymore (now built into the shell script).

Regarding macOS: I don't know if the Qt5 GUI builds or runs on any version of macOS.

I included the qmake flag -spec macx-g++ on macOS as in make-c5makefile.sh and make-qcodeeditmakefile.sh.

I suspect the architecture dependent stuff for macOS in those files is now obsolete. I find the options CONFIG += x86 etc. mentioned explicitly only in Qt4 documentation:
https://doc.qt.io/archives/qt-4.8/deployment-mac.html#architecture-dependencies
but not in later documentation:
https://doc.qt.io/qt-5/macos-deployment.html
(the whole section is gone).

Since checking for the architecture as in make-c5makefile.sh (by compiling another program and then examining the resulting binary) would complicate the check considerably with doubtful benefit, I did not incorporate any of this into qt5-check.sh.

Please let me know if any issues remain (or adapt the script yourself as you see fit).

#26 Updated by John Abbott over 1 year ago

@Ulrich: great! Thanks!

Currently my old MacBook is rather unwell (me too), so I cannot check on MacOS.
I'll probably "inherit" Anna's slightly less old MacBook... sometime next year?

I'll check your script on my linux box.

#27 Updated by John Abbott over 1 year ago

  • Related to Design #1699: Shell scripts: Shebang line, etc added

#28 Updated by Ulrich von der Ohe over 1 year ago

As a test I built the GUI successfully on OpenBSD.

The process exposed also several several minor issues with the build scripts (at least some of which can also affect other systems). Patches are attached, along with a revised version of qt5-check.sh.

Some or all of these issues may already be fixed in your current development version. Still it would be nice if you could look at these patches and consider merging them, if possible. A changelog is below. Please let me know if anything is unclear or could be done better.

The attached patch file (buildscriptpatches) is intended to be applied to CoCoALib-0.99800 after the GUI has been patched with the patch from #1393#note-15 by running patch -p1 < buildscriptpatches from inside the CoCoALib directory. After applying the patch file, execute permissions to the newly created file configuration/qt5-check.sh must be set.

Alternatively, the attached shell script CoCoALib-0.99800_qt5gui+buildscriptpatches.sh can be used, which incorporates the patch from #1393#note-15, the revised qt5-check.sh and the build script patch.

Changelog (build scripts only):

1. configuration/qt5-check.sh: Revised and integrated (cf. 2, 8, 9).

2. configure:
  • Fixes concerning Boost headers and libraries (cf. 3, 4, 7).
  • Fixes concerning Readline headers (cf. 3, 5).
  • Use configuration/qt5-check.sh (cf. 1).
  • Fix concerning fPIC (cf. 6).
  • Build GUI by default if sufficient Qt5 system is found.
  • New option --no-qt-gui to disable building GUI.
  • Removed option --Qt-gui.
3. configuration/fixed_part2:
  • Fixes concerning Boost (cf. 2, 4, 7).
  • Fixes concerning Readline.

4. configuration/boost-check-arch.sh: Fixes concerning Boost (cf. 2, 3, 7).

5. configuration/readline-find-hdr.sh: Readline headers were not found on some systems (cf. 2, 3).

6. configuration/fpic-ldflag.sh:
  • No special treatment of Clang++: Leave out -Wl,-no_pie.
  • Integrate the only remaining option into configure (cf. 1).
    [My tests show that -Wl,-no_pie or -Wl,--no-pie each lead to problems
    on some systems (i.e. link time error). Thus, unless there are good
    reasons not to, I would suggest to leave -no_pie and --no-pie out.]
7. src/CoCoA-5/Makefile:
  • Fixes concerning Boost libraries (cf. 2, 3 4).
  • Pass CXX=$(CXX) to build GUI.
  • Using $(MAKE) instead of hard coded make.

8. src/CoCoA-5/make-qcodeeditmakefile.sh: Fixes concerning name of qmake executable (cf. 1, 9).

9. src/CoCoA-5/make-c5makefile.sh: Fixes concerning name of qmake executable (cf. 1, 8).

10. src/CoCoA-5/tests/Makefile: Error messages from RunTests.sh were redirected to /dev/null (cf. 11).

11. src/CoCoA-5/tests/RunTests.sh: Number of tests calculated correctly (cf. 10).

12. doc/Makefile: Fixes concerning txt2tags (cf. #1662).

13. doc/CoCoALib-tasks/Makefile: $(CXX) instead of hard coded g++.

#29 Updated by John Abbott over 1 year ago

Thanks, Ulrich!
I hope to look at this during the week. I had already made several changes regarding BOOST, so I'll merge
your changes in.

Impressed that you managed to compile on OpenBSD!

#30 Updated by John Abbott over 1 year ago

I am having trouble with the patch file. Many failed.
I'll email you my current sources, and hope you can produce a patch file against those.

#31 Updated by John Abbott over 1 year ago

Ulrich, maybe it is simpler to send me a tar.gz of your configuration directory...

#32 Updated by John Abbott over 1 year ago

Anna
Could you check Ulrich's changelog in note-28 above.
He has made some changes regarding BOOST and no-pie

Maybe we should arrange a 3-way Skype?

#33 Updated by John Abbott over 1 year ago

Ulrich suggests asking the QCodeEdit author if we distribute under GPLv3+

NOte: try website https://bruant.info (Hugues, Luc?)

#34 Updated by Ulrich von der Ohe over 1 year ago

It is still not clear to me what bothers you about the QCodeEdit license. As I said on the phone call you refer to, if you want QCodeEdit under a different license (the reason would not be clear to me at this point), then contacting its author to me seems necessary (and possible).

As I wrote here before, I think that any potential licensing issues should be discussed on their own since they have nothing to do with the issue at hand (the change from Qt4 to Qt5).

I attach a new version (for the time until your next release) of the Qt5 build system patch, fixing an issue when building on systems without Qt5.

#35 Updated by John Abbott over 1 year ago

I have just written to fullmetalcoder asking whether we may re-distribute QcodeEdit under GPLv3+ rather than GPLv3.

I'll look at the patch.

#36 Updated by John Abbott over 1 year ago

Email bounced.

#37 Updated by John Abbott over 1 year ago

The easy solution is to continue to distribute as we already do (with GPLv3+, but leaving the Qt stuff with GPLv3).
For a source release with some other licence, maybe we can skip the Qt code???

I'll have to modify the release script.

#38 Updated by John Abbott over 1 year ago

I have revised the release script, and also configure to handle the case of a source tree without the GUI code.

The release script will automatically exclude the GUI code unless the chosen copyright schema is GPLv3.

My simple tests passed. I'll leave the issue in feedback for the moment.

PS: auto excluding the GUI makes it trickier to create ad hoc TGZ files with complete sources & restrictive licence... Hmmm.

Also available in: Atom PDF