Menu

#2591 meet `'QtCore' file not found` problem when build from source on macOS

None
closed-not-a-bug
nobody
None
2024-03-22
2023-02-26
Qubicand
No
  • system version: macOS 12.6, M1 machine
  • source info: gnuplot-5.4.6
  • problem description: I wish gnuplot can both support qt and x11 terminal, but if install gnuplot via homebrew, only qt terminal is supported, and the option --with-x11 seems is removed (see Homebrew/brew not taking options when installing gnuplot), so I decide to build gunplot from source. But although I can successfully install and run qt version's gnuplot, I failed to build qt version's gnuplot from source. Exactly, I tried to compile gnuplot via
$ ./configure --with-qt=qt5
$ make

then meet error message

qtterminal/qt_term.cpp:51:10: fatal error: 'QtCore' file not found
#include <QtCore>
         ^~~~~~~~
1 error generated.
make[4]: *** [qtterminal/qt_term.o] Error 1
make[3]: *** [all-recursive] Error 1
make[2]: *** [all] Error 2
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2

However, I'm sure qt@5 is already installed via homebrew.

$ brew install qt@5
Warning: qt@5 5.15.5_3 is already installed and up-to-date.
To reinstall 5.15.5_3, run:
  brew reinstall qt@5

Discussion

  • Tatsuro MATSUOKA

    Sorry I do not familiar with the MacOS.

    The error you have met is your fault for qt install for develepment.

    Error does not come from the bug of gnuplot.

    At any platform and any program , you have to install proper 'development laibraries (libraries and header files)' of deprendencies when you build the application from source.

     
  • Tatsuro MATSUOKA

    • status: open --> open-not-a-bug
    • Group: -->
    • Priority: -->
     
  • Tatsuro MATSUOKA

    • status: open-not-a-bug --> open
     
  • Tatsuro MATSUOKA

    My writing in the above may be invalid.
    Please up load your config.log file.

     

    Last edit: Tatsuro MATSUOKA 2023-02-27
    • Qubicand

      Qubicand - 2023-02-27

      Thanks for your reply! The following attachment is my config.log after run the following command (as same as the former one)

      $ ./configure --with-qt=qt5
      $ make
      

      (In addition, as earlier mentioned, I noticed that qt-version can be correctly installed from homebrew, here is its .rb file homebrew-core/Formula/gnuplot.rb. I suspect perhaps the command inside def install will be helpful. However, neither C/C++ project or the rule of homebrew's .rb file are unfamiliar for me, so this is just a vary subjective comment. I hope it won't make a misleading if the judgement is incorrect.)

       

      Last edit: Qubicand 2023-02-27
      • Ethan Merritt

        Ethan Merritt - 2023-02-27

        I have never used homebrew so I can't offer much help, only guesses. Is it possible that homebrew installs qt5 as one big package rather than breaking it into the separate pieces Qt5Core Qt5Gui etc that gnuplot's configure script is looking for? If that is the case it may be correct that gnuplot will build successfully even though there are errors reported by the configure script when it doesn't find separate packages by those names. The homebrew recipe link you gave for gnuplot doesn't seem to show anything special required to configure and build it.

        Did your make actually produce a gnuplot executable? If so you are probably fine. If it failed, please upload the output from
        $ make >& make.log

        You might get useful help from a homebrew forum.

         
  • Tatsuro MATSUOKA

    Using a text editor, I checked a word 'qt' in config.log.

        line number    7:   $ ./configure --with-qt=qt5
        line number 6031: configure:16267: checking for QT
        line number 6032: configure:16275: $PKG_CONFIG --exists --print-errors "Qt5Core Qt5Gui Qt5Network Qt5Svg Qt5PrintSupport"
        line number 6033: Package Qt5Core was not found in the pkg-config search path.
        line number 6034: Perhaps you should add the directory containing `Qt5Core.pc'
        line number 6036: No package 'Qt5Core' found
        line number 6037: Package Qt5Gui was not found in the pkg-config search path.
        line number 6038: Perhaps you should add the directory containing `Qt5Gui.pc'
        line number 6040: No package 'Qt5Gui' found
        line number 6041: Package Qt5Network was not found in the pkg-config search path.
        line number 6042: Perhaps you should add the directory containing `Qt5Network.pc'
        line number 6044: No package 'Qt5Network' found
        line number 6045: Package Qt5Svg was not found in the pkg-config search path.
        line number 6046: Perhaps you should add the directory containing `Qt5Svg.pc'
        line number 6048: No package 'Qt5Svg' found
        line number 6049: Package Qt5PrintSupport was not found in the pkg-config search path.
        line number 6050: Perhaps you should add the directory containing `Qt5PrintSupport.pc'
        line number 6052: No package 'Qt5PrintSupport' found
        line number 6054: configure:16293: $PKG_CONFIG --exists --print-errors "Qt5Core Qt5Gui Qt5Network Qt5Svg Qt5PrintSupport"
        line number 6055: Package Qt5Core was not found in the pkg-config search path.
        line number 6056: Perhaps you should add the directory containing `Qt5Core.pc'
        line number 6058: No package 'Qt5Core' found
        line number 6059: Package Qt5Gui was not found in the pkg-config search path.
        line number 6060: Perhaps you should add the directory containing `Qt5Gui.pc'
        line number 6062: No package 'Qt5Gui' found
        line number 6063: Package Qt5Network was not found in the pkg-config search path.
        line number 6064: Perhaps you should add the directory containing `Qt5Network.pc'
        line number 6066: No package 'Qt5Network' found
        line number 6067: Package Qt5Svg was not found in the pkg-config search path.
        line number 6068: Perhaps you should add the directory containing `Qt5Svg.pc'
        line number 6070: No package 'Qt5Svg' found
        line number 6071: Package Qt5PrintSupport was not found in the pkg-config search path.
        line number 6072: Perhaps you should add the directory containing `Qt5PrintSupport.pc'
        line number 6074: No package 'Qt5PrintSupport' found
        line number 6076: No package 'Qt5Core' found
        line number 6077: No package 'Qt5Gui' found
        line number 6078: No package 'Qt5Network' found
        line number 6079: No package 'Qt5Svg' found
        line number 6080: No package 'Qt5PrintSupport' found
        line number 6082: Package requirements (Qt5Core Qt5Gui Qt5Network Qt5Svg Qt5PrintSupport) were not met:
        line number 6084: No package 'Qt5Core' found
        line number 6085: No package 'Qt5Gui' found
        line number 6086: No package 'Qt5Network' found
        line number 6087: No package 'Qt5Svg' found
        line number 6088: No package 'Qt5PrintSupport' found
        line number 6093: Alternatively, you may set the environment variables QT_CFLAGS
        line number 6094: and QT_LIBS to avoid the need to call pkg-config.
        line number 6097: configure:16516: result: The Qt terminal will use Qt5.
        line number 6129: config.status:1117: creating src/qtterminal/Makefile
        line number 6177: configure:18571: result:   Qt terminal: yes (qt5)
        line number 6261: ac_cv_env_QT_CFLAGS_set=
        line number 6262: ac_cv_env_QT_CFLAGS_value=
        line number 6263: ac_cv_env_QT_LIBS_set=
        line number 6264: ac_cv_env_QT_LIBS_value=
        line number 6458: ACLOCAL='${SHELL} '\''/Users/he/Downloads/gnuplot-5.4.6_qt/missing'\'' aclocal-1.16'
        line number 6467: AUTOCONF='${SHELL} '\''/Users/he/Downloads/gnuplot-5.4.6_qt/missing'\'' autoconf'
        line number 6468: AUTOHEADER='${SHELL} '\''/Users/he/Downloads/gnuplot-5.4.6_qt/missing'\'' autoheader'
        line number 6469: AUTOMAKE='${SHELL} '\''/Users/he/Downloads/gnuplot-5.4.6_qt/missing'\'' automake-1.16'
        line number 6481: BUILD_QT_FALSE='#'
        line number 6482: BUILD_QT_TRUE=''
        line number 6548: MAKEINFO='${SHELL} '\''/Users/he/Downloads/gnuplot-5.4.6_qt/missing'\'' makeinfo'
        line number 6567: QT_CFLAGS=''
        line number 6568: QT_LIBS=''
        line number 6619: install_sh='${SHELL} /Users/he/Downloads/gnuplot-5.4.6_qt/install-sh'
        line number 6788: #define QTTERM 1
        line number 6789: #define QTVER 5
    

    ./configure detects qt five and mention

        line number 6177: configure:18571: result:   Qt terminal: yes (qt5)
    

    However,

    :
    :
    :
        line number 6082: Package requirements (Qt5Core Qt5Gui Qt5Network Qt5Svg Qt5PrintSupport) were not met:
        line number 6084: No package 'Qt5Core' found
        line number 6085: No package 'Qt5Gui' found
        line number 6086: No package 'Qt5Network' found
        line number 6087: No package 'Qt5Svg' found
        line number 6088: No package 'Qt5PrintSupport' found
    

    However, requried pacakges, Qt5core, Qt5Gui, Qt5Network, Qt5PrintSupport and Qt5Svg were not found.
    I think that ./configure should report qt was "no".
    This might be a bug for configuration system of gnuplot.

    BTW, perhaps your installation of Qt is for users.
    If you want to build gnuplot from source, all depedencies libraries should be installed for developpers.
    On Ubuntu, qtbase5-dev, libqt5svg5-dev and qttools5-dev are required for building gnuplot.
    Corresponding tools for MacOS should be required.
    Sorry I have never used the mac computers, the aboves are all I can tell you.

     

    Last edit: Tatsuro MATSUOKA 2023-02-27
    • Qubicand

      Qubicand - 2023-02-27

      Thanks for your suggestion! It seems I need more time to learn how to use qt on macOS. If later I found any new discovers, I will post them here.

       
  • Tatsuro MATSUOKA

    Hi Ethan.
    configure result configure:18571: result: Qt terminal: yes (qt5),
    while Qt5core, Qt5Gui, Qt5Network, Qt5PrintSupport and Qt5Svg were not found. ???
    Is this a bug?

     
    • Ethan Merritt

      Ethan Merritt - 2023-02-27

      It may be a bug in the configure script. I do not have a Mac system to use for testing. I guess the problem would be that if the command is ./configure --with-qt it will set qt5 if that is the system default, qt4 if that is the system default, and will fail if there is no system default and it cannot find either qt4 or qt5. If you tell it --with-qt=qt5 that sets the qt5 flag to start with and the bug is that the flag is not cleared when it cannot find the libraries. I will see if I can reproduce the problem on a linux system.

      I have never used homebrew myself, but I see that the homebrew site https://formulae.brew.sh/formula/qt@5 lists the following dependencies for building programs with qt support:

      Depends on when building from source:
          node    19.7.0  Platform built on V8 to build network applications
          pkg-config  0.29.2  Manage compile and link flags for libraries
          python@3.10 3.10.10 Interpreted, interactive, object-oriented programming language
      

      I would start by making sure that the packages qt@5 node pkg-config and python@3.10 are installed before running the gnuplot configure script.

       
  • Hiroki Motoyoshi

    It may be that pkg-config does not recognize qt5 installed with homebrew (I don't know why).

    Please, try the following command,

    env CXXFLAGS=' -std=c++11 ' PKG_CONFIG_PATH=/usr/local/opt/qt5/lib/pkgconfig \
        configure --with-qt=qt5 
    

    CXXFLAGS above is necessary in my environment, but I don't know if it is necessary in yours.

     
    • Qubicand

      Qubicand - 2023-03-01

      Thanks for your help, the command is does work! It seems the solution is just help gnuplot find those packages. However, since my directory of qt5/lib/pkgconfig is different from yours (which is installed via homebrew), I changed it into the actual path in my computer as following

      $ CXXFLAGS=' -std=c++11 ' PKG_CONFIG_PATH='/opt/homebrew/opt/qt5/lib/pkgconfig' \
      configure --with-qt
      

      Now qt can be detected even didn't explicitly tell qt's version like --with-qt=qt5. The following shows one part of the output from above command

      ...
      X Window System terminal: yes  (multi-byte fonts OK)
          (enable plotting to windows opened by external apps)
        libgd-based png, jpeg, and gif terminals: yes (with animated gif)
        cairo-based pdf and png terminals: yes
        lua/TikZ terminal: yes
        wxt terminal: no (requires C++, wxWidgets>2.6, cairo>0.9, pango>1.22)
        Qt terminal: yes (qt5)
      ...
      

      Then I can run the build command without the previous 'QtCore' file not found error

      $ make
      $ make check
      $ make install
      

      Finally, after building, I run ./src/gnuplot and check its supported terminal

      $ ./src/gnuplot
      
          G N U P L O T
          Version 5.4 patchlevel 6    last modified 2023-02-09
      
          Copyright (C) 1986-1993, 1998, 2004, 2007-2023
          Thomas Williams, Colin Kelley and many others
      
          gnuplot home:     http://www.gnuplot.info
          faq, bugs, etc:   type "help FAQ"
          immediate help:   type "help"  (plot window: hit 'h')
      
      Terminal type is now 'qt'
      gnuplot> set terminal
      

      and the output is as following

      Available terminal types:
             cairolatex  LaTeX picture environment using graphicx package and Cairo backend
                 canvas  HTML Canvas object
                    cgm  Computer Graphics Metafile
                context  ConTeXt with MetaFun (for PDF documents)
                domterm  DomTerm terminal emulator with embedded SVG
                   dumb  ascii art for anything that prints text
                    dxf  dxf-file for AutoCad (default size 120x80)
                    emf  Enhanced Metafile format
               epscairo  eps terminal based on cairo
               epslatex  LaTeX picture environment using graphicx package
                    fig  FIG graphics language V3.2 for XFIG graphics editor
                    gif  GIF images using libgd and TrueType fonts
                   hpgl  HP7475 and relatives [number of pens] [eject]
                   jpeg  JPEG images using libgd and TrueType fonts
                    lua  Lua generic terminal driver
                     mf  Metafont plotting standard
                     mp  MetaPost plotting standard
                   pcl5  PCL5e/PCL5c printers using HP-GL/2
               pdfcairo  pdf terminal based on cairo
                 pict2e  LaTeX2e picture environment
                    png  PNG images using libgd and TrueType fonts
               pngcairo  png terminal based on cairo
             postscript  PostScript graphics, including EPSF embedded files (*.eps)
                pslatex  LaTeX picture environment with PostScript \specials
                  pstex  plain TeX with PostScript \specials
               pstricks  LaTeX picture environment with PSTricks macros
                     qt  Qt cross-platform interactive terminal
                sixelgd  sixel using libgd and TrueType fonts
                    svg  W3C Scalable Vector Graphics
                tek40xx  Tektronix 4010 and others; most TEK emulators
                tek410x  Tektronix 4106, 4107, 4109 and 420X terminals
                texdraw  LaTeX texdraw environment
                   tikz  TeX TikZ graphics macros via the lua script driver
               tkcanvas  Tk canvas widget
                unknown  Unknown terminal type - not a plotting device
                  vttek  VT-like tek40xx terminal emulator
                    x11  X11 Window System interactive terminal
                   xlib  X11 Window System (dump of gnuplot_x11 command stream)
                  xterm  Xterm Tektronix 4014 Mode
      

      which shows both qt and x11 is supported.

      (In addition, I checked the path qt5/lib/pkgconfig, find the file such as Qt5Core.pc, Qt5Gui.pc are inside it, but those packages can't be found in make process.)

      Now this issues seems can be closed.

       
  • Qubicand

    Qubicand - 2023-03-01
    • status: open --> closed-not-a-bug
     
  • Ethan Merritt

    Ethan Merritt - 2023-03-01

    Great news that you're up and running.

    Would you be willing to write a brief summary that I could add to the INSTALL file explaining what you did to build + install on homebrew? It might save time the next time this comes up; even if the person who runs into a problem doesn't find the summary in INSTALL at least I'll know where to point them if they ask here or on the mailing list.

    Was it just

    $ brew install qt@5
    $ CXXFLAGS=' -std=c++11 ' PKG_CONFIG_PATH='/opt/homebrew/opt/qt5/lib/pkgconfig' \
    configure --with-qt
    $ make
    

    or was there more to it (perhaps other stuff you had already found and installed earlier)?

     
    • Qubicand

      Qubicand - 2023-03-02

      Yes, no problem. I'm very please to share my experience to help more people.

      I split the whole process as two parts: install dependencies and compile.

      1. Install dependencies: before I decide to compile gnuplot by myself, I've already installed gnuplot via homebrew, therefore also installed its dependence. Although qt@5 is necessarily needed to install, I'm not sure if one can successfully compile gnuplot without others. Therefore, I strongly suggest also install those dependences before starting to compile. From homebrew
      $ brew info gnuplot
      ==> gnuplot: stable 5.4.4 (bottled), HEAD
      Command-driven, interactive function plotting
      http://www.gnuplot.info/
      /opt/homebrew/Cellar/gnuplot/5.4.4 (46 files, 2.8MB) *
        Poured from bottle on 2023-02-26 at 21:19:58
      From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/gnuplot.rb
      License: gnuplot
      ==> Dependencies
      Build: pkg-config ✔
      Required: gd ✔, libcerf ✔, lua ✔, pango ✔, qt@5 ✔, readline ==> Options
      --HEAD
          Install HEAD version
      

      One can either manually install those dependencies by

      $ brew install pkg-config gd libcerf lua pango qt@5 readline
      

      or just simply install gnuplot via homebrew, in this time the dependencies will automatically installed

      $ brew install gnuplot
      

      in the time I write this text, gnuplot installed by homebrew is compiled with qt by default, but no option can allow compiling with x11. Therefore, if one just wish to use gnuplot with qt but don't care if it can run with x11, it's enough to install via homebrew and no need to compile by oneself. However, if one wishes to hold both features, it seems compiling gnuplot by oneself is unavoidable.
      2. Compile gnuplot with qt: If no extra option, run ./configure and make will automatically compile gnuplot with x11 support. However, if wish compile with qt, one need to add option --with-qt (detailed descriptions about these options can be found by ./configure -h). However, it seems if qt5 is installed via homebrew, gnuplot can't automatically detect it*, and then run make command one will meet problem like fatal error: 'QtCore' file not found (detailed discussion see #2591 meet 'QtCore' file not found problem when build from source on macOS). To solve the problem, one need to add an extra command before ./configure --with-qt to tell where to find lib like QtCore

      $ CXXFLAGS=' -std=c++11 ' PKG_CONFIG_PATH='/opt/homebrew/opt/qt5/lib/pkgconfig' \
      configure --with-qt
      

      Note if your qt5/lib/pkgconfig is installed otherwhere, one need to change the path inside the above command (one example see here). After that, one can then compile gnuplot as usual

      $ make
      $ make check
      $ sudo make install
      

      Note for macOS, the sudo prefix at the last line is seems necessary, which may due to there is some file operations which required sudo permission.

       
      👍
      1

      Last edit: Qubicand 2023-03-02
  • Samuel Unicomb

    Samuel Unicomb - 2024-03-22

    I can add that this advice resolved the fatal error: QtCore file not found error for me on macOS Monterey 12.6.8. I'm building gnuplot-6.0.0 from source.

    I had to run export PKG_CONFIG_PATH=/usr/local/opt/qt@5/lib/pkgconfig/, which was not working without export.

    I then configured with ./configure --with-qt=qt5.

    Thanks for the helpful thread.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.