strawberrymusicplayer / strawberry

:strawberry: Strawberry Music Player
https://www.strawberrymusicplayer.org/
GNU General Public License v3.0
2.74k stars 192 forks source link

Building against QT6: QT_SQLITE_TEST failed #1471

Closed z1atk0 closed 4 months ago

z1atk0 commented 4 months ago

Describe the bug When trying to build against Qt6 using -DBUILD_WITH_QT6=ON, the test for the availability of SQLite fails. The test app itself compiles fine, but running it produces an error message and a segfault. From build/CMakeFiles/CMakeConfigureLog.yaml (I'll attach the complete file below):

[...]
    runResult:
      variable: "QT_SQLITE_TEST_EXITCODE"
      cached: true
      stdout: |
      stderr: |
        QSqlDatabase requires a QCoreApplication
        QSqlDatabase requires a QCoreApplication
        Segmentation fault
      exitCode: "FAILED_TO_RUN"

Googling for "QSqlDatabase requires a QCoreApplication" produces only very few hits, but no actual hint as to what the problem might be and/or how to fix it (or at least it's not obvious to me :man_shrugging:). The macros producing this error message are defined in Qt's src/sql/kernel/qsqldatabase.cpp lines 22-31.

The actual build process (for strawberry itself) then completes fine without problems, and produces a working binary (minus any features that require SQLite, of course).

Building against Qt5 using -DBUILD_WITH_QT5=ON does detect the availability of SQLite properly, and also produces a working binary ...

[...]
    runResult:
      variable: "SQLITE_FTS5_TEST_EXITCODE"
      cached: true
      stdout: |
      stderr: |
      exitCode: 0

... but warns of Qt5's deprecation, which prompted me to try building against Qt6 in the first place:

CMake Warning at CMakeLists.txt:558 (message):
  It is detected that Strawberry is being built with Qt 5.  There are no
  bugfix releases for the latest minor LTS version of Qt 5 available to
  open-source users, only commercial users.  Therefore Strawberry should be
  built with Qt 6 when possible.  Building with Qt 6 will also take advantage
  of improvements and new features not available in Qt 5.  To build with Qt 6
  specify -DBUILD_WITH_QT6=ON to automatically detect Qt 6, or for example
  -DCMAKE_PREFIX_PATH=/usr/local/lib64/cmake to manually specify the Qt 6
  directory.

To Reproduce mkdir build && cd build && cmake .. -DBUILD_WITH_QT6=ON

Expected behavior I expected the configure run to properly detect that SQLite is in fact available with Qt6 on my system. :slightly_smiling_face:

Screenshots: N/A

System Information:

Additional context Qt5-5.1513 & Qt6-6.7.2 (both with SQLite support :wink:), sqlite-autoconf-3460000 (ie. 3.46.0), cmake-3.29.6, gcc/c++-11.2.0. If you need any additional info just let me know.

Qt5 configure log (-DBUILD_WITH_QT5=ON): CMakeConfigureLog.yaml.txt Qt6 configure log (-DBUILD_WITH_QT6=ON): CMakeConfigureLog.yaml.txt

Thanks for listening, Thomas

z1atk0 commented 4 months ago

Wow, that was quick, thank you! :+1: However, it now fails one step further with exactly the same error messages as before, but on SQLITE_FTS5_TEST this time:

[zlatko@disclosure:~/usrlocal/src]$ tail -10 strawberry-1.0.23/build/CMakeFiles/CMakeConfigureLog.yaml 
    runResult:
      variable: "SQLITE_FTS5_TEST_EXITCODE"
      cached: true
      stdout: |
      stderr: |
        QSqlDatabase requires a QCoreApplication
        QSqlDatabase requires a QCoreApplication
        Segmentation fault
      exitCode: "FAILED_TO_RUN"
...

I guess the required fix is trivial, ie. apply exactly the same patch as before, only a second time a few lines down the CMakeLists.txt in the test app for SQLITE_FTS5_TEST as well. :nerd_face:

jonaski commented 4 months ago

Strawberry does not use FTS5 anymore so that test has been removed.