Uploaded image for project: 'Qbs ("Cubes")'
  1. Qbs ("Cubes")
  2. QBS-1617

Linker error when compiling against Qt 6.0.0 Alpha/Beta (cannot find -l-pthread)

    XMLWordPrintable

Details

    • Linux/X11

    Description

      There appears an -l-pthread entry on the linker command-line that is causing trouble:

      ERROR: /usr/lib/ccache/g++ -Wl,-soname=libtiledquick.so,--as-needed,-m,elf_x86_64,-rpath,/home/bjorn/Qt/6.0.0/gcc_64/lib -shared -L/home/bjorn/Qt/6.0.0/gcc_64/lib -m64 -o /home/bjorn/projects/tiled/default/libtiledquick.11f78142/libtiledquick.so /home/bjorn/projects/tiled/default/libtiledquick.11f78142/3a52ce780950d4d9/mapitem.cpp.o /home/bjorn/projects/tiled/default/libtiledquick.11f78142/3a52ce780950d4d9/maploader.cpp.o /home/bjorn/projects/tiled/default/libtiledquick.11f78142/3a52ce780950d4d9/tilelayeritem.cpp.o /home/bjorn/projects/tiled/default/libtiledquick.11f78142/3a52ce780950d4d9/tilesnode.cpp.o /home/bjorn/projects/tiled/default/libtiledquick.11f78142/73489b871e127538/moc_mapitem.cpp.o /home/bjorn/projects/tiled/default/libtiledquick.11f78142/73489b871e127538/moc_maploader.cpp.o /home/bjorn/projects/tiled/default/libtiledquick.11f78142/73489b871e127538/moc_mapref.cpp.o /home/bjorn/projects/tiled/default/libtiledquick.11f78142/73489b871e127538/moc_tilelayeritem.cpp.o /home/bjorn/Qt/6.0.0/gcc_64/lib/libQt6Quick.so.6.0.0 /home/bjorn/Qt/6.0.0/gcc_64/lib/libQt6QmlModels.so.6.0.0 /home/bjorn/Qt/6.0.0/gcc_64/lib/libQt6Qml.so.6.0.0 /home/bjorn/Qt/6.0.0/gcc_64/lib/libQt6OpenGL.so.6.0.0 /home/bjorn/Qt/6.0.0/gcc_64/lib/libQt6Network.so.6.0.0 /home/bjorn/projects/tiled/default/libtiled.080f31f8/libtiled.so /home/bjorn/Qt/6.0.0/gcc_64/lib/libQt6Gui.so.6.0.0 /home/bjorn/Qt/6.0.0/gcc_64/lib/libQt6Core.so.6.0.0 /home/bjorn/Qt/6.0.0/gcc_64/lib/libQt6QmlModels.so /home/bjorn/Qt/6.0.0/gcc_64/lib/libQt6Qml.so -l-pthread /home/bjorn/Qt/6.0.0/gcc_64/lib/libQt6Gui.so /home/bjorn/Qt/6.0.0/gcc_64/lib/libQt6Core.so -lGLX -lOpenGL -lpthread
      
      ERROR: /usr/bin/ld: cannot find -l-pthread
      collect2: error: ld returned 1 exit status
      ERROR: Process failed with exit code 1.
      

      This problem does not happen with the same Qbs version but compiling against Qt 5.15.1.

      Searching through the auto-generated Qt modules, I find several "-pthread" entries in dynamicLibsRelease properties that should probably be "pthread" entries:

      bjorn@thor:~/projects/tiled/default/genmodules/Qt/d5d4cd07616a5428$ grep -Irn pthread 
      d46821bae07cf44b/modules/Qt/core/core.qbs:70:    property stringList dynamicLibsRelease: ["pthread"]
      d46821bae07cf44b/modules/Qt/bootstrap-private/module.qbs:11:    staticLibsRelease: ["pthread","z"]
      84267398099612f5/modules/Qt/quicktest/module.qbs:13:    dynamicLibsRelease: ["-pthread"]
      84267398099612f5/modules/Qt/waylandclient/module.qbs:13:    dynamicLibsRelease: ["-pthread","wayland-client","wayland-cursor"]
      84267398099612f5/modules/Qt/help/module.qbs:13:    dynamicLibsRelease: ["-pthread"]
      84267398099612f5/modules/Qt/qml/qml.qbs:35:    dynamicLibsRelease: ["-pthread"]
      84267398099612f5/modules/Qt/uitools/module.qbs:13:    dynamicLibsRelease: ["-pthread"]
      84267398099612f5/modules/Qt/core/core.qbs:70:    property stringList dynamicLibsRelease: ["pthread"]
      84267398099612f5/modules/Qt/designer/module.qbs:13:    dynamicLibsRelease: ["-pthread"]
      84267398099612f5/modules/Qt/svg/module.qbs:13:    dynamicLibsRelease: ["-pthread"]
      

      Some further analysis based on discussion on Discord showed that these values are taken from Qt's .prl files (most files left out for brevity, but about 22 files in total are affected, with 20 other files using -lpthread instead):

      bjorn@thor:~/Qt/6.0.0/gcc_64/lib$ grep -Irn "LIBS =.*\-l\-pthread" *.prl
      ...
      libQt6Qml.prl:5:QMAKE_PRL_LIBS = -lQt6Network -lQt6Core -l-pthread
      libQt6QmlWorkerScript.prl:5:QMAKE_PRL_LIBS = $$[QT_INSTALL_LIBS]/libQt6Qml.so -lQt6Network -lQt6Core -l-pthread
      libQt6QuickControls2Impl.prl:5:QMAKE_PRL_LIBS = -lQt6Quick -lQt6QmlModels -lQt6OpenGL -lQt6Gui -lGLX -lOpenGL -lQt6Qml -lQt6Network -lQt6Core -l-pthread
      libQt6QuickControls2.prl:5:QMAKE_PRL_LIBS = -lQt6Quick -lQt6QmlModels -lQt6OpenGL -lQt6Gui -lGLX -lOpenGL -lQt6Qml -lQt6Network -lQt6Core -l-pthread
      ...
      

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              kandeler Christian Kandeler
              bjorn Thorbjørn Lindeijer
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes