Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Problem building qtbase from source



  • I’ve downloaded the offline installer qt-opensource-linux-x64-5.14.2.run file onto my ubuntu 18.04 system. Executing that .run file a few months ago seemed to build all of the Qt libraries, and I’ve been linking may application against them with no problem since then. Now I want to modify some code in the qtbase libraries and I want to build with ‘make’. So I cd to $QT_HOME/5.14.2/Src/qtbase, and I type ‘qmake’; this prompts me with questions about which edition I want to use and whether I accept the license terms, and then qmake configures things for the Makefile (I put the output at the end of this post). I then run ‘make’ which runs for about an hour but then fails:

    make[2]: Entering directory '/home/oreilly/Qt5.14.2/5.14.2/Src/qtbase/qmake'
    make[2]: *** No rule to make target 'binary'.  Stop.
    make[2]: Leaving directory '/home/oreilly/Qt5.14.2/5.14.2/Src/qtbase/qmake'
    Makefile.qmake-aux:965: recipe for target '/home/oreilly/Qt5.14.2/5.14.2/Src/qtbase/qmake/qmake' failed
    make[1]: *** [/home/oreilly/Qt5.14.2/5.14.2/Src/qtbase/qmake/qmake] Error 2
    

    Does anyone know why? Below is the output from the ‘qmake’ step.
    Thanks!

    Selecting Qt Edition.
     
    Type 'c' if you want to use the Commercial Edition.
    Type 'o' if you want to use the Open Source Edition.
     
    Which edition of Qt do you want to use? 
    This is the Qt Open Source Edition.
     
    You are licensed to use this software under the terms of
    the GNU Lesser General Public License (LGPL) version 3
    or the GNU General Public License (GPL) version 2.
     
    Type 'L' to view the GNU Lesser General Public License version 3 (LGPLv3).
    Type 'G' to view the GNU General Public License version 2 (GPLv2).
    Type 'y' to accept this license offer.
    Type 'n' to decline this license offer.
     
    Do you accept the terms of either license? 
     
    Running configuration tests...
    Done running configuration tests.
     
    Configure summary:
     
    Build type: linux-g++ (x86_64, CPU features: mmx sse sse2)
    Compiler: gcc 7.5.0
    Configuration: sse2 aesni sse3 ssse3 sse4_1 sse4_2 avx avx2 avx512f avx512bw avx512cd avx512dq avx512er avx512ifma avx512pf avx512vbmi avx512vl compile_examples enable_new_dtags f16c largefile precompile_header rdrnd shani x86SimdAlways shared shared rpath release c++11 c++14 c++1z concurrent dbus reduce_exports reduce_relocations stl
    Build options:
      Mode ................................... release
      Optimize release build for size ........ no
      Building shared libraries .............. yes
      Using C standard ....................... C11
      Using C++ standard ..................... C++17
      Using ccache ........................... no
      Using new DTAGS ........................ yes
      Relocatable ............................ yes
      Using precompiled headers .............. yes
      Using LTCG ............................. no
      Target compiler supports:
        SSE .................................. SSE2 SSE3 SSSE3 SSE4.1 SSE4.2
        AVX .................................. AVX AVX2
        AVX512 ............................... F ER CD PF DQ BW VL IFMA VBMI
        Other x86 ............................ AES F16C RDRAND SHA
        Intrinsics without -mXXX option ...... yes
      Build parts ............................ libs examples tools
    Qt modules and options:
      Qt Concurrent .......................... yes
      Qt D-Bus ............................... yes
      Qt D-Bus directly linked to libdbus .... no
      Qt Gui ................................. yes
      Qt Network ............................. yes
      Qt Sql ................................. yes
      Qt Testlib ............................. yes
      Qt Widgets ............................. yes
      Qt Xml ................................. yes
    Support enabled for:
      Using pkg-config ....................... yes
      udev ................................... no
      Using system zlib ...................... yes
      Zstandard support ...................... no
    Qt Core:
      DoubleConversion ....................... yes
        Using system DoubleConversion ........ no
      GLib ................................... yes
      iconv .................................. no
      ICU .................................... yes
      Built-in copy of the MIME database ..... yes
      Tracing backend ........................ <none>
      Logging backends:
        journald ............................. no
        syslog ............................... no
        slog2 ................................ no
      PCRE2 .................................. yes
        Using system PCRE2 ................... no
    Qt Network:
      getifaddrs() ........................... yes
      IPv6 ifname ............................ yes
      libproxy ............................... no
      Linux AF_NETLINK ....................... yes
      OpenSSL ................................ yes
        Qt directly linked to OpenSSL ........ no
      OpenSSL 1.1 ............................ yes
      DTLS ................................... yes
      OCSP-stapling .......................... yes
      SCTP ................................... no
      Use system proxies ..................... yes
      GSSAPI ................................. no
    Qt Gui:
      Accessibility .......................... yes
      FreeType ............................... yes
        Using system FreeType ................ yes
      HarfBuzz ............................... yes
        Using system HarfBuzz ................ yes
      Fontconfig ............................. yes
      Image formats:
        GIF .................................. yes
        ICO .................................. yes
        JPEG ................................. yes
          Using system libjpeg ............... yes
        PNG .................................. yes
          Using system libpng ................ yes
      Text formats:
        HtmlParser ........................... yes
        CssParser ............................ yes
        OdfWriter ............................ yes
        MarkdownReader ....................... yes
          Using system libmd4c ............... no
        MarkdownWriter ....................... yes
      EGL .................................... yes
      OpenVG ................................. no
      OpenGL:
        Desktop OpenGL ....................... yes
        OpenGL ES 2.0 ........................ no
        OpenGL ES 3.0 ........................ no
        OpenGL ES 3.1 ........................ no
        OpenGL ES 3.2 ........................ no
      Vulkan ................................. yes
      Session Management ..................... yes
    Features used by QPA backends:
      evdev .................................. yes
      libinput ............................... no
      INTEGRITY HID .......................... no
      mtdev .................................. no
      tslib .................................. no
      xkbcommon .............................. no
      X11 specific:
        XLib ................................. yes
        XCB Xlib ............................. yes
        EGL on X11 ........................... yes
    QPA backends:
      DirectFB ............................... no
      EGLFS .................................. yes
      EGLFS details:
        EGLFS OpenWFD ........................ no
        EGLFS i.Mx6 .......................... no
        EGLFS i.Mx6 Wayland .................. no
        EGLFS RCAR ........................... no
        EGLFS EGLDevice ...................... yes
        EGLFS GBM ............................ no
        EGLFS VSP2 ........................... no
        EGLFS Mali ........................... no
        EGLFS Raspberry Pi ................... no
        EGLFS X11 ............................ yes
      LinuxFB ................................ yes
      VNC .................................... yes
    Qt Sql:
      SQL item models ........................ yes
    Qt Widgets:
      GTK+ ................................... no
      Styles ................................. Fusion Windows
    Qt PrintSupport:
      CUPS ................................... no
    Qt Sql Drivers:
      DB2 (IBM) .............................. no
      InterBase .............................. no
      MySql .................................. yes
      OCI (Oracle) ........................... no
      ODBC ................................... yes
      PostgreSQL ............................. yes
      SQLite2 ................................ no
      SQLite ................................. yes
        Using system provided SQLite ......... no
      TDS (Sybase) ........................... no
    Qt Testlib:
      Tester for item models ................. yes
     
    Qt is now configured for building. Just run 'make'.
    Once everything is built, you must run 'make install'.
    Qt will be installed into '/home/oreilly/Qt/5.14.2/gcc_64'.
     
    Prior to reconfiguration, make sure you remove any leftovers from
    the previous build.
    

  • Qt Champions 2019

    @Tom-asso said in Problem building qtbase from source:

    Executing that .run file a few months ago seemed to build all of the Qt libraries

    It did not build anything as the installer contains prebuild libraries.

    "and I type ‘qmake’" - use absolute path to qmake to make sure you use the correct qmake.
    Also you should do out of source build:

    mkdir qt_build
    cd qt_build
    PATH_TO_QMAKE/qmake PATH_TO_QT_SRC/qtbase
    make -j 4
    

    Use "-j n" parameter where n is the number of logical cores of your CPU. Will accelerate the build.



  • @jsulm - thanks, I followed your suggested steps, but make gets an error looking for a vulkan header:

    % mkdir ~/qt-build
    % cd ~/qt-build
     
    % which qmake
    /home/oreilly/Qt/5.14.2/gcc_64/bin/qmake  # This is the correct qmake
     
    % qmake ~/Qt/5.14.2/Src/qtbase/ 2>&1 | tee qmake.out
    % make -j 4 2>&1 | tee make.out
     
     [ After several minutes ]
     
    /home/oreilly/Qt5.14.2/5.14.2/Src/qtbase/include/QtGui/5.14.2/QtGui/private/qvulkanfunctions_p.h:1:10: fatal error: ../../../../../src/gui/vulkan/qvulkanfunctions_p.h: No such file or directory
     #include "../../../../../src/gui/vulkan/qvulkanfunctions_p.h"
              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    compilation terminated.
    

    I do see that vulkan header file in my QT source directory, but in a different path (i.e. not in "src/gui/vulkan"):

    $QT_HOME/5.14.2/Src/qtbase/include/QtGui/5.14.2/QtGui/private/qvulkanfunctions_p.h

    qtbase/src/gui/vulkan contains qvulkanfunctions.cpp, but not the header file.

    Here is the configuration summary generated by the qmake step:

    Configure summary:
    
    Build type: linux-g++ (x86_64, CPU features: mmx sse sse2)
    Compiler: gcc 7.5.0
    Configuration: sse2 aesni sse3 ssse3 sse4_1 sse4_2 avx avx2 avx512f avx512bw avx512cd avx512dq avx512er avx512ifma avx512pf avx512vbmi avx512vl compile_examples enable_new_dtags f16c largefile precompile_header rdrnd shani x86SimdAlways shared shared rpath release c++11 c++14 c++1z concurrent dbus reduce_exports reduce_relocations stl
    Build options:
      Mode ................................... release
      Optimize release build for size ........ no
      Building shared libraries .............. yes
      Using C standard ....................... C11
      Using C++ standard ..................... C++17
      Using ccache ........................... no
      Using new DTAGS ........................ yes
      Relocatable ............................ yes
      Using precompiled headers .............. yes
      Using LTCG ............................. no
      Target compiler supports:
        SSE .................................. SSE2 SSE3 SSSE3 SSE4.1 SSE4.2
        AVX .................................. AVX AVX2
        AVX512 ............................... F ER CD PF DQ BW VL IFMA VBMI
        Other x86 ............................ AES F16C RDRAND SHA
        Intrinsics without -mXXX option ...... yes
      Build parts ............................ libs examples tools
    Qt modules and options:
      Qt Concurrent .......................... yes
      Qt D-Bus ............................... yes
      Qt D-Bus directly linked to libdbus .... yes
      Qt Gui ................................. yes
      Qt Network ............................. yes
      Qt Sql ................................. yes
      Qt Testlib ............................. yes
      Qt Widgets ............................. yes
      Qt Xml ................................. yes
    Support enabled for:
      Using pkg-config ....................... yes
      udev ................................... no
      Using system zlib ...................... yes
      Zstandard support ...................... no
    Qt Core:
      DoubleConversion ....................... yes
        Using system DoubleConversion ........ no
      GLib ................................... yes
      iconv .................................. no
      ICU .................................... yes
      Built-in copy of the MIME database ..... yes
      Tracing backend ........................ <none>
      Logging backends:
        journald ............................. no
        syslog ............................... no
        slog2 ................................ no
      PCRE2 .................................. yes
        Using system PCRE2 ................... no
    Qt Network:
      getifaddrs() ........................... yes
      IPv6 ifname ............................ yes
      libproxy ............................... no
      Linux AF_NETLINK ....................... yes
      OpenSSL ................................ yes
        Qt directly linked to OpenSSL ........ no
      OpenSSL 1.1 ............................ yes
      DTLS ................................... yes
      OCSP-stapling .......................... yes
      SCTP ................................... no
      Use system proxies ..................... yes
      GSSAPI ................................. no
    Qt Gui:
      Accessibility .......................... yes
      FreeType ............................... yes
        Using system FreeType ................ yes
      HarfBuzz ............................... yes
        Using system HarfBuzz ................ yes
      Fontconfig ............................. yes
      Image formats:
        GIF .................................. yes
        ICO .................................. yes
        JPEG ................................. yes
          Using system libjpeg ............... yes
        PNG .................................. yes
          Using system libpng ................ yes
      Text formats:
        HtmlParser ........................... yes
        CssParser ............................ yes
        OdfWriter ............................ yes
        MarkdownReader ....................... yes
          Using system libmd4c ............... no
        MarkdownWriter ....................... yes
      EGL .................................... yes
      OpenVG ................................. no
      OpenGL:
        Desktop OpenGL ....................... yes
        OpenGL ES 2.0 ........................ no
        OpenGL ES 3.0 ........................ no
        OpenGL ES 3.1 ........................ no
        OpenGL ES 3.2 ........................ no
      Vulkan ................................. yes
      Session Management ..................... yes
    Features used by QPA backends:
      evdev .................................. yes
      libinput ............................... no
      INTEGRITY HID .......................... no
      mtdev .................................. no
      tslib .................................. no
      xkbcommon .............................. no
      X11 specific:
        XLib ................................. yes
        XCB Xlib ............................. yes
        EGL on X11 ........................... yes
    QPA backends:
      DirectFB ............................... no
      EGLFS .................................. yes
      EGLFS details:
        EGLFS OpenWFD ........................ no
        EGLFS i.Mx6 .......................... no
        EGLFS i.Mx6 Wayland .................. no
        EGLFS RCAR ........................... no
        EGLFS EGLDevice ...................... yes
        EGLFS GBM ............................ no
        EGLFS VSP2 ........................... no
        EGLFS Mali ........................... no
        EGLFS Raspberry Pi ................... no
        EGLFS X11 ............................ yes
      LinuxFB ................................ yes
      VNC .................................... yes
    Qt Sql:
      SQL item models ........................ yes
    Qt Widgets:
      GTK+ ................................... no
      Styles ................................. Fusion Windows
    Qt PrintSupport:
      CUPS ................................... no
    Qt Sql Drivers:
      DB2 (IBM) .............................. no
      InterBase .............................. no
      MySql .................................. yes
      OCI (Oracle) ........................... no
      ODBC ................................... yes
      PostgreSQL ............................. yes
      SQLite2 ................................ no
      SQLite ................................. yes
        Using system provided SQLite ......... no
      TDS (Sybase) ........................... no
    Qt Testlib:
      Tester for item models ................. yes
    
    Qt is now configured for building. Just run 'make'.
    Once everything is built, you must run 'make install'.
    Qt will be installed into '/home/oreilly/Qt/5.14.2/gcc_64'.
    
    Prior to reconfiguration, make sure you remove any leftovers from
    the previous build.
    
    

  • Lifetime Qt Champion

    Hi,

    qtbase is not built with qmake.

    If you modify it, just call make in the root folder of your qtbase build. You can be more precise using the Ce option with the sub folder you actually want to build.



  • Thanks @SGaist - we are still talking about the code installed by executing qt-opensource-linux-x64-5.14.2.run, right? Because I do not see a Makefile in the qtbase subdirectory:

    % ls ~/Qt5.14.2/5.14.2/Src/qtbase/
    bin              header.BSD          header.MIT           LICENSE.QT-LICENSE-AGREEMENT
    config_help.txt  header.COMM         include              mkspecs
    config.tests     header.FDL          INSTALL              qmake
    configure        header.GPL          lib                  qtbase.pro
    configure.bat    header.GPL-EXCEPT   LICENSE.FDL          src
    configure.json   header.LGPL         LICENSE.GPL2         sync.profile
    configure.pri    header.LGPL3        LICENSE.GPL3         tests
    dist             header.LGPL3-COMM   LICENSE.GPL3-EXCEPT  util
    doc              header.LGPL-NOGPL2  LICENSE.LGPL3
    examples         header.LGPL-ONLY    LICENSE.LGPLv3
    

    That's why I originally ran 'qmake' in that directory, to generate a Makefile from qtbase.pro. But running 'make' with the generated Makefile gives the "*** No rule to make target 'binary'" error after several minutes.


  • Lifetime Qt Champion

    To build qtbase, you have to call configure. qmake is built as part of the bootstrap process.



  • @SGaist Thanks again SGaist - my apologies for all the questions, but is the procedure for building sources that come from the downloaded .run file (e.g qt-opensource-linux-x64-5.14.2.run) documented somewhere? As you suggest, I now run ./configure (instead of qmake directly), but still have problems.

    When I execute qt-opensource-linux-x64-5.14.2.run on my ubuntu 18.04 system, it places files including sources and shared libraries in $HOME/Qt5.14.2.. I can link my application with the shared libraries in $HOME/Qt5.14.2/5.14.2/gcc_64/

    Now I want to modify some source files in Qt5.14.2 qtbase

    % cd 5.14.2/Src/qtbase
    % ./configure   # builds (and runs?) qmake, generates Makefile
    

    Now if I run ‘make’ it successfully runs to completion. If I modify a qtbase source file and run ‘make’ again, it successfully builds. However ‘make’ rebuilds the libraries in 5.14.2/Src/qtbase/lib - but my app is linking with 5.14.2/gcc_64/lib. How do I “install” the rebuilt libraries into that directory? Is it ‘make install’? I tried “make install”, but it fails:

    % make install
     
    cd src/ && ( test -e Makefile || /home/oreilly/Qt5.14.2/5.14.2/Src/qtbase/bin/qmake -o Makefile /home/oreilly/Qt5.14.2/5.14.2/Src/qtbase/src/src.pro ) && make -f Makefile install
    make[1]: Entering directory '/home/oreilly/Qt5.14.2/5.14.2/Src/qtbase/src'
    cd tools/bootstrap/ && ( test -e Makefile || /home/oreilly/Qt5.14.2/5.14.2/Src/qtbase/bin/qmake -o Makefile /home/oreilly/Qt5.14.2/5.14.2/Src/qtbase/src/tools/bootstrap/bootstrap.pro ) && make -f Makefile install
    make[2]: Entering directory '/home/oreilly/Qt5.14.2/5.14.2/Src/qtbase/src/tools/bootstrap'
    /home/oreilly/Qt5.14.2/5.14.2/Src/qtbase/bin/qmake -install qinstall ../../../lib/libQt5Bootstrap.a /usr/local/Qt-5.14.2/lib/libQt5Bootstrap.a
    Error copying ../../../lib/libQt5Bootstrap.a to /usr/local/Qt-5.14.2/lib/libQt5Bootstrap.a: Destination file exists
    Makefile:14154: recipe for target 'install_target' failed
    make[2]: *** [install_target] Error 3
    make[2]: Leaving directory '/home/oreilly/Qt5.14.2/5.14.2/Src/qtbase/src/tools/bootstrap'
    Makefile:82: recipe for target 'sub-bootstrap-install_subtargets' failed
    make[1]: *** [sub-bootstrap-install_subtargets] Error 2
    make[1]: Leaving directory '/home/oreilly/Qt5.14.2/5.14.2/Src/qtbase/src'
    Makefile:62: recipe for target 'sub-src-install_subtargets' failed
    make: *** [sub-src-install_subtargets] Error 2
    

    If I just manually copy all libraries from 5.14.2/Src/qtbase/lib to 5.14.2/gcc_64/lib, then link my application with those, it gives this error:

    /home/oreilly/Qt5.14.2/5.14.2/gcc_64/lib/libQt5Qml.so: undefined reference to `operator delete[](void*, unsigned long)@Qt_5'
    /home/oreilly/Qt5.14.2/5.14.2/gcc_64/lib/libQt5Quick.so: undefined reference to `operator delete(void*, unsigned long)@Qt_5'
    collect2: error: ld returned 1 exit status
    Makefile:373: recipe for target 'mbgrdviz-2' failed
    

    So I am still missing something...


  • Qt Champions 2019

    @Tom-asso Since you're you're installing into /usr/local you should call make install with sudo.



  • @jsulm - ah, you are right of course!


  • Lifetime Qt Champion

    Note that if you want to hack on Qt itself, you can use the developer-build and it will do an in place build. However it should not be used to build software releases as it toggles some flags for development.



  • @SGaist - could you please explain? What is the "developer build", and what is the "development.3" flag?
    I would like to modify qtdatavisualization3d for my app, then freely distribute to users on a non-commercial basis - which source file should I be using in that case?
    Thanks!


  • Lifetime Qt Champion

    The 3 was a typo.
    As I wrote, it will trigger an in-place build, meaning that you won't have to call make install each time you want to test your modifications.

    In that case, you should only build that module rather than the whole of Qt.



  • @SGaist - thanks. Earlier you mentioned a "Ce" option to specify a particular sub-folder to build. Can you please refer me to a page describing how to use that?
    Thanks!



  • @SGaist - after building in-place with 'make', the libraries are scattered among many different subdirectories. What is the best way to link against those, when there are in so many different places?
    Thanks!


  • Lifetime Qt Champion

    Did you do a build from scratch after adding that option to your configure line ?

    With a developer build you should have all binaries in qtbase/bin and the libraries in qtbase/lib.



  • @SGaist - yes I see them there, thanks.
    Earlier you mentioned a "Ce" option to specify a particular sub-folder to build. Can you please refer me to a page describing how to use that?
    Thanks!



  • I do not see a qtcreator executable after building qt-everywhere-src-5.14.2. Is that expected?
    I built with these configure options: -qt-xcb -recheck-all -debug -developer-build


  • Lifetime Qt Champion

    Yes it is to be expected, Qt Creator is a independent project.


Log in to reply