Menu

#2649 v5.4.9 fails to build with Qt 6

None
closed-fixed
nobody
None
2023-12-30
2023-09-05
No

Hello 👋 . I'm a maintainer for the Homebrew project. While packaging v5.4.9 we are running into a build error with Qt 6:

uic-qt6 -o ui_QtGnuplotSettings.h qtterminal/QtGnuplotSettings.ui make[4]: uic-qt6: No such file or directory make[4]: *** [ui_QtGnuplotSettings.h] Error 1
Relates to https://github.com/Homebrew/homebrew-core/pull/141412

Discussion

  • Ethan Merritt

    Ethan Merritt - 2023-09-05

    I do not have direct experience with macOS or Homebrew, but perhaps this will help to diagnose or fix the problem.

    The uic and moc utilities are part of the Qt internationalization support. They were fully integrated into Qt5, but seem to have been incompletely forward-ported to Qt6. To mitigate this, there is a Qt5/Qt6 compatibility subsystem Qt6Core5Compat that unfortunately does not work quite the same way as the other Qt6 subsystems. In particular it seems not to have a well-defined policy for where its components are installed. Two possible paths are provided in the pkgconfig file

    Qt6Core5Compat.pc:
       bindir=${prefix}/lib64/qt6/bin
       libexecdir=${prefix}/lib64/qt6/libexec
    

    The uic executable itself is installed as ${prefix}/lib64/qt6/libexec/uic
    That's a little bit odd (the Qt5 uic was installed in bindir rather than libexecdir), but anyhow that's where gnuplot's configure script looks for it first.

    After that it gets more idiosyncratic. In order to allow installation of both Qt5 and Qt6, there are symlinks uic-qt5 and uic-qt6. On one of my test machines these were both created in /usr/bin but on another they were created as /usr/lib64/qt5/bin/uic-qt5 and /usr/lib64/qt6/bin/uic-qt6. On the other hand, that second machine adds those .../qtX/bin directories to PATH at login, so effectively both machines make the executables available simply as "uic-qt6". So that's what the gnuplot configure script falls back to, and is apparently what is happening on your machine.

    The same issue applies to moc and to rcc.

    So there are at least three levels at which this might be failing on your machine.

    1. Qt6Core5Compat might not be installed
    2. It might be installed but there is not a corresponding pkg-config file provided. See earlier report https://sourceforge.net/p/gnuplot/feature-requests/560/
    3. There is a pkg-config file but it doesn't match what gnuplot's configure script expects. In this case if you report back where the Qt6 uic/moc/rcc actually are located, I'll see if the configure script can be suitably modified to find them or at least print a suggestion for pre-defining an environmental variable to match.
     
  • Patrick Linnane

    Patrick Linnane - 2023-09-06

    uic/moc/rcc are located in libexec, but they do not have the "-qt6" suffix, which I believe is the issue we are having.

     
    • Ethan Merritt

      Ethan Merritt - 2023-09-06

      Hmm. I take it that the libexec dir is not reported by pkg-config --variable=libexecdir Qt6Core. If it were corretly reported, that should match gnuplot's first tested alternative. Does it fail because the Qt6Core.pc file is missing, or does pkg-config report a directory that doesn't match the actual installation path? Or is it that we need to specifically query $PKG_CONFIG --variable=libexecdir Qt6Core5Compat? IOW is there something that the configure script can do better?

      I am surprised that they would be installed in a top level system directory (no versioned subdirectory) with no suffix to distinguish the Qt version. Does the Homebrew environment not support having more than one Qt version installed?

       
      • Patrick Linnane

        Patrick Linnane - 2023-09-06

        I apologize if I didn't provide enough information. We do support having multiple versions of Qt installed. Here is the full path for uic with Qt 6:

        #{HOMEBREW_PREFIX}/Cellar/qt/6.5.1_3/share/qt/libexec/uic

        #{HOMEBREW_PREFIX} is /usr/local/ on Intel and /opt/homebrew/on Apple Silicon machines.

         
        • Ethan Merritt

          Ethan Merritt - 2023-09-06

          OK, but how should the configure script know this?
          My understanding is that the way this is supposed to work is that the script does

          QT6LOC=pkg-config --variable=libexecdir
          which in your case should result in QT6LOC=${HOMEBREW_PREFIX}/Cellar/qt/6.5.1_3/share/qt/libexec
          and the configure script then sets UIC=${QT6LOC}/uic which would succeed. Something in there is failing. Can we fix it?

           
          • FX

            FX - 2023-09-06

            Hi, other Homebrew maintainer here. Qt6 does not ship pkgconfig files, so we run configure with explicit paths to the right binaries set in MOC, UIC and RCC. This is working with gnuplot 5.4.8 and fails with 5.4.9. Somehow how UIC value is not obeyed.


            Our full configure line is:

            ./configure --disable-dependency-tracking --disable-silent-rules --prefix=/opt/homebrew/Cellar/gnuplot/5.4.9 --with-readline=/opt/homebrew/opt/readline --disable-wxwidgets --with-qt --without-x --without-latex MOC=/opt/homebrew/opt/qt/share/qt/libexec/moc RCC=/opt/homebrew/opt/qt/share/qt/libexec/rcc UIC=/opt/homebrew/opt/qt/share/qt/libexec/uic QT_CFLAGS=-I/opt/homebrew/opt/qt/include/QtCore -I/opt/homebrew/opt/qt/include/QtGui -I/opt/homebrew/opt/qt/include/QtNetwork -I/opt/homebrew/opt/qt/include/QtSvg -I/opt/homebrew/opt/qt/include/QtPrintSupport -I/opt/homebrew/opt/qt/include/QtWidgets -I/opt/homebrew/opt/qt/include/QtCore5Compat QT_LIBS=-F/opt/homebrew/opt/qt/Frameworks -framework QtCore -framework QtGui -framework QtNetwork -framework QtSvg -framework QtPrintSupport -framework QtWidgets -framework QtCore5Compat
            
             

            Last edit: FX 2023-09-06
            • FX

              FX - 2023-09-06

              Looking at this commit https://github.com/gnuplot/gnuplot/commit/098cd3883416e7c1617b719ac9dfa8277c5c3000#diff-49473dca262eeab3b4a43002adb08b4db31020d190caaad1594b47f1d5daa810R1013
              you can see that configure.ac was made to set UIC=uic-qt6, even if it was defined by user, which should not be the case.

               
              • Ethan Merritt

                Ethan Merritt - 2023-09-06

                Got it.
                Can you confirm that this patch to the configure script would fix things for you?

                --- ../gnuplot-5.4.9/configure  2023-08-25 20:13:06.000000000 -0700
                +++ ./configure 2023-09-06 12:10:59.677145000 -0700
                @@ -16393,7 +16393,7 @@ fi
                           UIC=${QT6LOC}/uic
                           MOC=${QT6LOC}/moc
                           RCC=${QT6LOC}/rcc
                
                -      else
                +      elif test "x${UIC}" = "x"; then
                           UIC=uic-qt6
                           MOC=moc-qt6
                           RCC=rcc-qt6
                
                 
                • Patrick Linnane

                  Patrick Linnane - 2023-09-06

                  That helped. We are encountering a new error now:

                  lrelease-qt6 qtterminal/po/qtgnuplot_fr.ts -qm qtgnuplot_fr.qm
                  make[4]: lrelease-qt6: No such file or directory
                  
                   
                  • Ethan Merritt

                    Ethan Merritt - 2023-09-06

                    It figures. Same story, different Qt package. lrelease is in qttools6. OK, here's a somewhat larger patch that hopefully catches lrelease as well as the others.

                    --- configure.549       2023-08-25 20:13:06.000000000 -0700
                    +++ configure   2023-09-06 14:10:44.149262630 -0700
                    @@ -16393,12 +16393,18 @@ fi
                               UIC=${QT6LOC}/uic
                               MOC=${QT6LOC}/moc
                               RCC=${QT6LOC}/rcc
                    
                    -      else
                    +      elif test "x${UIC}" = "x"; then
                               UIC=uic-qt6
                               MOC=moc-qt6
                               RCC=rcc-qt6
                           fi
                    -      LRELEASE=lrelease-qt6
                    +      QT6BIN=`$PKG_CONFIG --variable=bindir Qt6Core`
                    +      if test "x${QT6BIN}" != "x"; then
                    +          LRELEASE=${QT6BIN}/lrelease
                    +      elif test "x${LRELEASE}" = "x"; then
                    +          LRELEASE=lrelease-qt6
                    +      fi
                    +
                           CXXFLAGS="$CXXFLAGS -fPIC"
                           { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: The Qt terminal will use Qt6." >&5
                    
                     
                    • Patrick Linnane

                      Patrick Linnane - 2023-09-09

                      Unfortunately the same error with lrelease-qt6 persists despite using this updated patch.

                       
                      • Ethan Merritt

                        Ethan Merritt - 2023-09-09

                        Are you defining LRELEASE before running ./configure, as I gather you are doing for UIC MOC and RCC? Is the lrelease binary installed somewhere outside the Qt6 hierarchy? Is QT6BIN defined but the lrelease binary is not there?

                        Thanks for your patience in working this out. I face the same problem that the configure script does - I don't know where to look for these things without some help from the local environment.

                        Stepping outside this particular issue for a moment, is there a global reason why Homebrew does not or cannot use pkg-config? Even if an upstream library does not already provide a suitable .pc file, I would have guessed it easier to create one that serves all Homebrew client packages rather than having to work through this sort of package-by-package tweaking to make up for the lack of a global solution.

                         
                        • Patrick Linnane

                          Patrick Linnane - 2023-09-09

                          Thank you for the pointer. Using the configure patch and defining the LRELEASE location fixed the issue and I was able to build gnuplot 5.4.9 successfully. Here is the final formula (package definition) including the configure patch:

                          class Gnuplot < Formula
                            desc "Command-driven, interactive function plotting"
                            homepage "http://www.gnuplot.info/"
                            url "https://downloads.sourceforge.net/project/gnuplot/gnuplot/5.4.9/gnuplot-5.4.9.tar.gz"
                            sha256 "a328a021f53dc05459be6066020e9a71e8eab6255d3381e22696120d465c6a97"
                            license "gnuplot"
                          
                            livecheck do
                              url :stable
                              regex(%r{url=.*?/gnuplot[._-]v?(\d+(?:\.\d+)+)\.t}i)
                            end
                          
                            bottle do
                              sha256 arm64_ventura:  "d40df5c11e7f90b5ef3c489dff54bf405cf9125cda3de61f8fc24d0b3fcafd05"
                              sha256 arm64_monterey: "2b0b0ae3446b80af02452bb2ff1f2a787c41ac3627bd7499bbb96ce35bac62ae"
                              sha256 arm64_big_sur:  "52ed9426cb08b1bf9140ba75dcd6ef7b398fcf00c8f7246f1c93868f7b6570ab"
                              sha256 ventura:        "3bea5e9917bda062beed8195e92bf1a4a723d344a522d1d1cd028e393e65d797"
                              sha256 monterey:       "d416ea34c5dced922f6044f8d7ad0e273de282cd50182292f404bb0e5ff00d0f"
                              sha256 big_sur:        "7d3ec01a6fc4c7ead43f764f26153a7c4346a84fecb87e4c015ac661074fdc2e"
                              sha256 x86_64_linux:   "8a135d55cfe11b50e512cdad44b0a4be38bafa39d13f5828027fee46057cc032"
                            end
                          
                            head do
                              url "https://git.code.sf.net/p/gnuplot/gnuplot-main.git", branch: "master"
                          
                              depends_on "autoconf" => :build
                              depends_on "automake" => :build
                              depends_on "libtool" => :build
                            end
                          
                            depends_on "pkg-config" => :build
                            depends_on "gd"
                            depends_on "libcerf"
                            depends_on "lua"
                            depends_on "pango"
                            depends_on "qt"
                            depends_on "readline"
                          
                            fails_with gcc: "5"
                          
                            # Fixes `uic-qt6: No such file or directory`
                            # Fixes `lrelease-qt6: No such file or directory`
                            # https://sourceforge.net/p/gnuplot/bugs/2649/
                            patch :DATA
                          
                            def install
                              args = %W[
                                --disable-silent-rules
                                --with-readline=#{Formula["readline"].opt_prefix}
                                --disable-wxwidgets
                                --with-qt
                                --without-x
                                --without-latex
                                LRELEASE=#{Formula["qt"].bin}/lrelease
                                MOC=#{Formula["qt"].pkgshare}/libexec/moc
                                RCC=#{Formula["qt"].pkgshare}/libexec/rcc
                                UIC=#{Formula["qt"].pkgshare}/libexec/uic
                              ]
                          
                              if OS.mac?
                                # pkg-config files are not shipped on macOS, making our job harder
                                # https://bugreports.qt.io/browse/QTBUG-86080
                                # Hopefully in the future gnuplot can autodetect this information
                                # https://sourceforge.net/p/gnuplot/feature-requests/560/
                                qtcflags = []
                                qtlibs = %W[-F#{Formula["qt"].opt_prefix}/Frameworks]
                                %w[Core Gui Network Svg PrintSupport Widgets Core5Compat].each do |m|
                                  qtcflags << "-I#{Formula["qt"].opt_include}/Qt#{m}"
                                  qtlibs << "-framework Qt#{m}"
                                end
                          
                                args += %W[
                                  QT_CFLAGS=#{qtcflags.join(" ")}
                                  QT_LIBS=#{qtlibs.join(" ")}
                                ]
                              end
                          
                              ENV.append "CXXFLAGS", "-std=c++17" # needed for Qt 6
                              system "./prepare" if build.head?
                              system "./configure", *std_configure_args.reject { |s| s["--disable-debug"] },
                                                    *args
                              ENV.deparallelize # or else emacs tries to edit the same file with two threads
                              system "make"
                              system "make", "install"
                            end
                          
                            test do
                              system "#{bin}/gnuplot", "-e", <<~EOS
                                set terminal dumb;
                                set output "#{testpath}/graph.txt";
                                plot sin(x);
                              EOS
                              assert_predicate testpath/"graph.txt", :exist?
                            end
                          end
                          __END__
                          diff --git a/configure b/configure
                          index c918ea8..019dcc0 100755
                          --- a/configure
                          +++ b/configure
                          @@ -16393,12 +16393,17 @@ fi
                                     UIC=${QT6LOC}/uic
                                     MOC=${QT6LOC}/moc
                                     RCC=${QT6LOC}/rcc
                          
                          -      else
                          +      elif test "x${UIC}" = "x"; then
                                     UIC=uic-qt6
                                     MOC=moc-qt6
                                     RCC=rcc-qt6
                                 fi
                          -      LRELEASE=lrelease-qt6
                          +      QT6BIN=`$PKG_CONFIG --variable=bindir Qt6Core`
                          +      if test "x${QT6BIN}" != "x"; then
                          +          LRELEASE=${QT6BIN}/lrelease
                          +      elif test "x${LRELEASE}" = "x"; then
                          +          LRELEASE=lrelease-qt6
                          +      fi
                                 CXXFLAGS="$CXXFLAGS -fPIC"
                                 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: The Qt terminal will use Qt6." >&5
                           printf "%s\n" "The Qt terminal will use Qt6." >&6; }
                          
                           

                          Last edit: Patrick Linnane 2023-09-09
  • Ethan Merritt

    Ethan Merritt - 2023-09-18
    • status: open --> pending-fixed
    • Group: -->
    • Priority: -->
     
  • Ethan Merritt

    Ethan Merritt - 2023-12-30
    • Status: pending-fixed --> closed-fixed
     

Log in to post a comment.

MongoDB Logo MongoDB