Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build qt-libs5 for Linux #2

Open
phoe opened this issue Jan 14, 2022 · 22 comments
Open

Build qt-libs5 for Linux #2

phoe opened this issue Jan 14, 2022 · 22 comments
Assignees

Comments

@phoe
Copy link

phoe commented Jan 14, 2022

Leaving it here so someone can assign this to me.

@phoe
Copy link
Author

phoe commented Jan 14, 2022

I have run into https://bugreports.qt.io/browse/QTBUG-89977 which seemingly is not fixed on Qt5 5.14.2. I'm figuring out how to try and use GCC 10 to build Qt.

@phoe
Copy link
Author

phoe commented Jan 14, 2022

Same on clang:

In file included from /home/phoe/Projects/Qt/qtbase/src/corelib/codecs/qutfcodec.cpp:43:
In file included from ../include/QtCore/qendian.h:1:
In file included from ../include/QtCore/../../src/corelib/global/qendian.h:44:
In file included from ../include/QtCore/qfloat16.h:1:
../include/QtCore/../../src/corelib/global/qfloat16.h:295:7: error: explicit specialization of undeclared template class 'numeric_limits'
class numeric_limits<QT_PREPEND_NAMESPACE(qfloat16)> : public numeric_limits<float>
      ^             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../include/QtCore/../../src/corelib/global/qfloat16.h:295:63: error: unknown template name 'numeric_limits'
class numeric_limits<QT_PREPEND_NAMESPACE(qfloat16)> : public numeric_limits<float>
                                                              ^
../include/QtCore/../../src/corelib/global/qfloat16.h:333:18: error: explicit specialization of non-template class 'numeric_limits'
template<> class numeric_limits<const QT_PREPEND_NAMESPACE(qfloat16)>

@phoe
Copy link
Author

phoe commented Jan 14, 2022

@phoe
Copy link
Author

phoe commented Jan 14, 2022

Looks like the build of qtbase succeeded after patching. The commands I used were:

$ ./configure -opensource -release -nomake tests -nomake examples -c++std c++14 -confirm-license -force-debug-info -platform linux-clang
$ gmake -j6

@phoe
Copy link
Author

phoe commented Jan 14, 2022

Waiting for #3 to get fixed - I have no idea whether I should pull from qt master or if there are any custom patches that I should depend on.

@phoe
Copy link
Author

phoe commented Jan 14, 2022

Vanilla qtwebengine, tag 5.14.2. Issuing gmake results in the following:

In file included from ../../3rdparty/chromium/third_party/perfetto/src/base/unix_task_runner.cc:17:
In file included from ../../3rdparty/chromium/third_party/perfetto/include/perfetto/ext/base/unix_task_runner.h:21:
../../3rdparty/chromium/third_party/perfetto/include/perfetto/base/task_runner.h:48:55: error: unknown type name 'uint32_t'
  virtual void PostDelayedTask(std::function<void()>, uint32_t delay_ms) = 0;
                                                      ^
In file included from ../../3rdparty/chromium/third_party/perfetto/src/base/unix_task_runner.cc:17:
../../3rdparty/chromium/third_party/perfetto/include/perfetto/ext/base/unix_task_runner.h:69:66: error: non-virtual member function marked 'override' hides virtual member function
  void PostDelayedTask(std::function<void()>, uint32_t delay_ms) override;
                                                                 ^
../../3rdparty/chromium/third_party/perfetto/include/perfetto/base/task_runner.h:48:16: note: hidden overloaded virtual function 'perfetto::base::TaskRunner::PostDelayedTask' declared here: type mismatch at 2nd parameter ('int' vs 'uint32_t' (aka 'unsigned int'))
  virtual void PostDelayedTask(std::function<void()>, uint32_t delay_ms) = 0;
               ^
2 errors generated.

That's perfetto, a chromium dependency - I have no idea how to work around this one. Did you encounter anything like that @luismbo ?

@phoe
Copy link
Author

phoe commented Jan 14, 2022

OK - seems like adding a #include <cstdint> and #include <stddef> at random helped with that one. Removing a -Walland-Wextra` from ninja configuration helped with another two. The build is going on; I'll let it run overnight and hope it doesn't crash again.

Ah, the joys of C++ building.

I hate C++ as much as I enjoy Qt.

@phoe
Copy link
Author

phoe commented Jan 15, 2022

Another error, and I'm stumped this time:

In file included from ../../3rdparty/chromium/base/stl_util.h:27:
../../3rdparty/chromium/base/optional.h:346:61: error: no member named 'value' in 'std::is_constructible<blink::LayoutUnit, const base::Optional<blink::LayoutUnit> &>'
              std::is_constructible<T, const Optional<U>&>::value ||
              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
../../3rdparty/chromium/base/optional.h:471:39: note: in instantiation of template class 'base::internal::IsConvertibleFromOptional<blink::LayoutUnit, blink::LayoutUnit>' requested here
                           !internal::IsConvertibleFromOptional<T, U>::value &&
                                      ^
../../3rdparty/chromium/base/optional.h:474:3: note: while substituting prior template arguments into non-type template parameter [with U = blink::LayoutUnit]
  Optional(const Optional<U>& other) : internal::OptionalBase<T>(other) {}
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/type_traits:946:54: note: while substituting deduced template arguments into function template 'Optional' [with U = blink::LayoutUnit, $1 = (no value)]
    : public __bool_constant<__is_constructible(_Tp, _Args...)>
                                                     ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/type_traits:953:16: note: in instantiation of template class 'std::__is_constructible_impl<blink::LayoutUnit, const base::Optional<blink::LayoutUnit> &>' requested here
      : public __is_constructible_impl<_Tp, _Args...>
               ^
../../3rdparty/chromium/base/optional.h:560:16: note: in instantiation of template class 'std::is_constructible<blink::LayoutUnit, const base::Optional<blink::LayoutUnit> &>' requested here
          std::is_constructible<T, U>::value &&
               ^
../../3rdparty/chromium/base/optional.h:422:37: note: while substituting deduced template arguments into function template 'operator=' [with U = const base::Optional<blink::LayoutUnit> &]
class OPTIONAL_DECLSPEC_EMPTY_BASES Optional
                                    ^
../../3rdparty/chromium/third_party/blink/renderer/core/layout/ng/ng_constraint_space.h:538:10: note: while declaring the implicit copy assignment operator for 'RareData'
  struct RareData {
         ^

It seems that https://www.cplusplus.com/reference/type_traits/is_constructible/ has a member named value, at least in the standard, but here the compiler complains about it not being there. Wat.

@phoe
Copy link
Author

phoe commented Jan 15, 2022

Managed to build qtwebengine after some long time of screaming into the void*; attaching my patch here.

qtwebengine-3rdparty.diff.txt

EDIT: I forgot about one case where the build complains about a missing .hh file in an #include, but just rename the file to .h and it'll work.

@phoe
Copy link
Author

phoe commented Jan 15, 2022

CMake issues for the time being.

The instructions say:

cmake .. -G "Visual Studio 16 2019" -DCMAKE_INSTALL_PREFIX=%cd%\..\..\smokegen-install -DQt5_DIR="%cd%\..\..\qtbase" -DCMAKE_BUILD_TYPE=Release

It seems that the directory ../../qtbase contains the proper stuff:

┌─[phoe][helix][±][clang ✓][~/Projects/Qt/smokegen/build]
└─▪ ls ../../qtbase
bin              config.opt      configure       dist        header.COMM        header.LGPL         header.LGPL-ONLY  lib           LICENSE.GPL3-EXCEPT           Makefile  qtbase.pro    util
config.cache     config.status   configure.bat   doc         header.FDL         header.LGPL3        header.MIT        LICENSE.FDL   LICENSE.LGPL3                 mkspecs   src
config_help.txt  config.summary  configure.json  examples    header.GPL         header.LGPL3-COMM   include           LICENSE.GPL2  LICENSE.LGPLv3                plugins   sync.profile
config.log       config.tests    configure.pri   header.BSD  header.GPL-EXCEPT  header.LGPL-NOGPL2  INSTALL           LICENSE.GPL3  LICENSE.QT-LICENSE-AGREEMENT  qmake     tests

Also:

┌─[phoe][helix][~/Projects/Qt]
└─▪ find qtbase -name "Qt5Config.cmake"
qtbase/lib/cmake/Qt5/Qt5Config.cmake

But cmake still cannot find qtbase:

┌─[phoe][helix][±][clang ✓][~/Projects/Qt/smokegen/build]
└─▪ cmake .. -DQt5_DIR=../../qtbase -DCMAKE_INSTALL_PREFIX=../../smokegen-install -DCMAKE_BUILD_TYPE=Release
CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.


CMake Error at CMakeLists.txt:9 (find_package):
  By not providing "FindQt5.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "Qt5", but
  CMake did not find one.

  Could not find a package configuration file provided by "Qt5" with any of
  the following names:

    Qt5Config.cmake
    qt5-config.cmake

  Add the installation prefix of "Qt5" to CMAKE_PREFIX_PATH or set "Qt5_DIR"
  to a directory containing one of the above files.  If "Qt5" provides a
  separate development package or SDK, be sure it has been installed.


-- Configuring incomplete, errors occurred!
See also "/home/phoe/Projects/Qt/smokegen/build/CMakeFiles/CMakeOutput.log".

@phoe
Copy link
Author

phoe commented Jan 15, 2022

OK - I've remade everything from scratch, including the directory structure. Same error.

┌─[phoe][helix][~/Projects/Qt]
└─▪ ls
bin  doc  include  lib  libexec  mkspecs  plugins  qml  resources  translations
┌─[phoe][helix][~/Projects/Qt]
└─▪ cd ../Qt_repo
┌─[phoe][helix][~/Projects/Qt_repo]
└─▪ ls
qtbase  qtdeclarative  qtquickcontrols2  qtsvg  qtwebchannel  qtwebengine  qtwebsockets  smokegen
┌─[phoe][helix][~/Projects/Qt_repo]
└─▪ cd smokegen/build/
┌─[phoe][helix][±][clang ✓][~/Projects/Qt_repo/smokegen/build]
└─▪ cmake .. -DCMAKE_INSTALL_PREFIX=/home/phoe/Projects/Qt/smokegen-install \
             -DQt5_DIR=../../qtbase \
             -DCMAKE_BUILD_TYPE=Release
CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.


CMake Error at CMakeLists.txt:9 (find_package):
  By not providing "FindQt5.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "Qt5", but
  CMake did not find one.

  Could not find a package configuration file provided by "Qt5" with any of
  the following names:

    Qt5Config.cmake
    qt5-config.cmake

  Add the installation prefix of "Qt5" to CMAKE_PREFIX_PATH or set "Qt5_DIR"
  to a directory containing one of the above files.  If "Qt5" provides a
  separate development package or SDK, be sure it has been installed.


-- Configuring incomplete, errors occurred!
See also "/home/phoe/Projects/Qt_repo/smokegen/build/CMakeFiles/CMakeOutput.log".

Help please?

@phoe
Copy link
Author

phoe commented Jan 15, 2022

It seems like some sort of pathing issue. With a different path, I was able to produce a different error message:

┌─[phoe][helix][±][clang ✓][~/Projects/Qt_repo/smokegen/build]
└─▪ cmake .. -DCMAKE_INSTALL_PREFIX=/home/phoe/Projects/Qt/smokegen-install -DQt5_DIR=/home/phoe/Projects/Qt/lib/cmake/Qt5/ -DCMAKE_BUILD_TYPE=Release
CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.


CMake Error at /home/phoe/Projects/Qt_repo/qtbase/lib/cmake/Qt5Core/Qt5CoreConfig.cmake:15 (message):
  The imported target "Qt5::Core" references the file

     "/home/phoe/Projects/Qt_repo/qtbase/../Qt_repo/qtbase//mkspecs/linux-clang"

  but this file does not exist.  Possible reasons include:

  * The file was deleted, renamed, or moved to another location.

  * An install or uninstall procedure did not complete successfully.

  * The installation package was faulty and contained

     "/home/phoe/Projects/Qt_repo/qtbase/lib/cmake/Qt5Core/Qt5CoreConfigExtras.cmake"

  but not all the files it references.

Call Stack (most recent call first):
  /home/phoe/Projects/Qt_repo/qtbase/lib/cmake/Qt5Core/Qt5CoreConfigExtras.cmake:52 (_qt5_Core_check_file_exists)
  /home/phoe/Projects/Qt_repo/qtbase/lib/cmake/Qt5Core/Qt5CoreConfig.cmake:207 (include)
  /home/phoe/Projects/Qt/lib/cmake/Qt5/Qt5Config.cmake:28 (find_package)
  CMakeLists.txt:9 (find_package)


-- Configuring incomplete, errors occurred!
See also "/home/phoe/Projects/Qt_repo/smokegen/build/CMakeFiles/CMakeOutput.log".

But the path /home/phoe/Projects/Qt_repo/qtbase/../Qt_repo/qtbase//mkspecs/linux-clang doesn't make sense because it effectively has a duplicated Qt_repo/Qt_repo component.

Edit: qtbase was configured with this command:

./configure -opensource -release -nomake tests -nomake examples -c++std c++14 \
            -confirm-license -force-debug-info -platform linux-clang -prefix ~/Projects/Qt/

@phoe
Copy link
Author

phoe commented Jan 21, 2022

@luismbo Do you have any ideas for what might be going wrong here?

@luismbo
Copy link
Contributor

luismbo commented Jan 21, 2022

I wonder if the installation step of qtbase is missing or your PATH is not pointing to the tools provided (and installed) by qtbase. Also, a coworker of mine suggested that using your distribution’s Qt packages (including the source packages) might save you some trouble. But it could very well introduce other issues, of course.

@phoe
Copy link
Author

phoe commented Jan 21, 2022

My $PATH is /usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/home/phoe/.local/bin so completely vanilla - I did not need to modify it at all so far.

I have installed qtbase into ~/Projects/Qt:

┌─[phoe][helix][~/Projects/Qt]
└─▪ ls
bin  doc  include  lib  libexec  mkspecs  plugins  qml  resources  translations

Without running make install on qtbase, other Qt projects did not even seem to know where to install themselves.

@luismbo
Copy link
Contributor

luismbo commented Jan 21, 2022

The README and https://doc.qt.io/qt-5/linux-building.html suggest your ~/Projects/Qt/bin needs to be added to the beginning of the PATH. 🤷‍♂️

@stassats
Copy link
Member

Does it need to be built from source even on linux?

@luismbo
Copy link
Contributor

luismbo commented Jan 21, 2022

Using the distribution-provided Qt headers and libraries might work, yes.

@phoe
Copy link
Author

phoe commented Jan 21, 2022

Does it need to be built from source even on linux?

I'm trying to build it from source on Linux. Probably it could work with debian-provided libs/sources, but then my way of building/deploying CommonQt5 is limited to Debian.

The README and https://doc.qt.io/qt-5/linux-building.html suggest your ~/Projects/Qt/bin needs to be added to the beginning of the PATH. man_shrugging

Done that:

┌─[phoe][helix][±][clang ✓][~/Projects/Qt_repo/smokegen/build]
└─▪ echo $PATH
/home/phoe/Projects/Qt/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/home/phoe/.local/bin

But nothing changed.

@Shinmera
Copy link
Contributor

Shinmera commented Jan 21, 2022

The purpose of building from source is so that we can build on distributions with older glibc, making the resulting binaries more portable. Grabbing libraries from a recent distribution will cause them to fail on other setups because of the glibc versioning headache.

I always had a specific VM with a debian system that was purposefully old to build my binaries with for this reason.

@phoe
Copy link
Author

phoe commented Jan 21, 2022

Yes, that too; forgot about that reason. Apologies, I'm half-brained today. But still, I remembered that there's a good reason to figure out the process of building from source on Linux.

So, yes, I'll want to keep on digging into this. In the worst case I'll need to spend some time time on learning cmake internals even if I'm not amused by the idea myself. :D

@stassats
Copy link
Member

I personally don't need prebuilt binaries, just a way to build smokgen/smokeqt. And even then, not just on linux, but macos as well. But the combination of different llvms make it hard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants