Important: Please read the Qt Code of Conduct -

Building PySide2 against static Qt

  • We're evaluating using Qt5 with WebAssembly for a client's web application. As such, the Qt5 build uses static instead of dynamic linking. We'd also like to be able to use Python bindings for test scripts, but trying to build PySide2 and Shiboken2 against a static Qt5 has been...troublesome so far. The linker always complains about undefined references, typically for pthread_* functions or dlclose. Example error messages:

    /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/8/ undefined reference to symbol 'pthread_setspecific@@GLIBC_2.2.5'
    /usr/bin/ld: //lib/x86_64-linux-gnu/ error adding symbols: DSO missing from command line
    /usr/bin/ld: /tmp/ccQkHWGA.ltrans21.ltrans.o: undefined reference to symbol 'dlclose@@GLIBC_2.2.5'
    /usr/bin/ld: //lib/x86_64-linux-gnu/ error adding symbols: DSO missing from command line
    collect2: error: ld returned 1 exit status
    make[2]: *** [generator/CMakeFiles/shiboken2.dir/build.make:181: generator/shiboken2] Error 1
    make[1]: *** [CMakeFiles/Makefile2:2878: generator/CMakeFiles/shiboken2.dir/all] Error 2
    make: *** [Makefile:141: all] Error 2
    error: Error compiling shiboken2

    Is it even possible to compile PySide2/Shiboken2 to utilize a statically-compiled version of Qt5, or would we have to use some kind of two-path setup for our project, using static Qt for the WebAssembly app and dynamic Qt for the bindings?

    Here are the build options used when building Qt and PySide:


    ./init-repository -f --module-subset=qtbase,qtdeclarative,qtwebsockets,qtsvg,qtquickcontrols,qtquickcontrols2,qtgraphicaleffects,qtxmlpatterns
    ./configure -opensource -confirm-license -release -static -nomake examples -no-dbus -no-headersclean -ltcg -no-ssl -strip -prefix /opt


    python3 build --qmake=/opt/bin/qmake --build-tests --ignore-git --parallel=8 --module-subset=Core

    We don't need any UI for the bindings, so we only attempt to build the Core module.

    The build environment is Debian Buster. Qt version is 5.12.2, PySide branch is 5.12.

  • I managed to get the build going by adding a good part of the build requirements for Qt as libraries to the PySide2 built by patching the CMakeLists.txt files for the ApiExtractor and the tools. I did have to exclude the Test, GUI and Network modules, though.

  • Can you please take a look at my question and reply

Log in to reply