[solved] Qt5.5 static build failed: QQmlDebugServerThread::run(): error: undefined reference to 'QTcpServerConnection::QTcpServerConnection()'

  • Hi there,

    I have a working version of Qt 5.5 dynamically compiling and linking - but now I move on to the deployment phase and I really need to make a single statically linked binary so that it is portable to other linux platforms.

    I did the following:
    Download and unpack: http://download.qt.io/official_releases/qt/5.5/5.5.0/single/qt-everywhere-opensource-src-5.5.0.tar.gz
    Run the following commands (from here link text):

    cd /home/al/Downloads/qt-everywhere-opensource-src-5.5.0
    ./configure -static -prefix /home/al/Downloads/qtBuild
    make -j 7 -w  // took a while but no errors
    make install  // This failed

    The error I got was:

    g++ -Wl,-O1 -fuse-ld=gold -Wl,--enable-new-dtags -o chatserver .obj/main.o .obj/chatserver.o .obj/websocketclientwrapper.o .obj/websockettransport.o .obj/chatserver_plugin_import.o .obj/moc_chatserver.o .obj/moc_websocketclientwrapper.o .obj/moc_websockettransport.o -L/home/al/Downloads/qt-everywhere-opensource-src-5.5.0/qtwebsockets/lib -lQt5WebSockets -L/home/al/Downloads/qt-everywhere-opensource-src-5.5.0/qtbase/lib -L/home/al/Downloads/qt-everywhere-opensource-src-5.5.0/qtwebchannel/lib -lQt5WebChannel -L/home/al/Downloads/qt-everywhere-opensource-src-5.5.0/qtdeclarative/lib -lQt5Qml -L/home/al/Downloads/qt-everywhere-opensource-src-5.5.0/qtbase/plugins/bearer -lqconnmanbearer -lqgenericbearer -lqnmbearer -lQt5Network -lQt5DBus -lQt5Core -lqtpcre -lm -ldl -lrt -lpthread
    /home/al/Downloads/qt-everywhere-opensource-src-5.5.0/qtdeclarative/lib/libQt5Qml.a(qqmldebugserver.o):qqmldebugserver.cpp:function QQmlDebugServerThread::run(): error: undefined reference to 'QTcpServerConnection::QTcpServerConnection()'
    collect2: error: ld returned 1 exit status
    make[4]: *** [chatserver] Error 1
    make[4]: Leaving directory /home/al/Downloads/qt-everywhere-opensource-src-5.5.0/qtwebchannel/examples/webchannel/chatserver-cpp' make[3]: *** [sub-chatserver-cpp-install_subtargets] Error 2 make[3]: Leaving directory/home/al/Downloads/qt-everywhere-opensource-src-5.5.0/qtwebchannel/examples/webchannel'
    make[2]: *** [sub-webchannel-install_subtargets] Error 2
    make[2]: Leaving directory /home/al/Downloads/qt-everywhere-opensource-src-5.5.0/qtwebchannel/examples' make[1]: *** [sub-examples-install_subtargets] Error 2 make[1]: Leaving directory/home/al/Downloads/qt-everywhere-opensource-src-5.5.0/qtwebchannel'
    make: *** [module-qtwebchannel-install_subtargets] Error 2

    I saw on some web pages that I may need to use the flag '-D QT_QML_NO_DEBUGGER', but this seems strange that the compile does not work - I am not doing anything people are not doing all the time (though this is the first time I have attempted static build), so I would expect to see more posts about this error. So I am assuming I have done something wrong...?

    Note the reason I used the prefix flag was so I don't over write my working qt5 installation, but if its easier to just use the default install location I am happy to "lose" the dynamic qt libraries and just over-write with the static version.

  • Hi,

    I am having the same exact error, after the same exact procedure.
    Is there any follow up on this topic?


  • Hi There,

    Yes, well... I finally found out that there is a combo of issues here, the main one being that the git source for 5.5.0 has a bug in it that won't allow static compile to work. I forget where exactly that bug lies been off the topic for too long : (

    Good news it that there is a fix for it in the latest code. Therefore it will be fixed in v5.5.1 when it is released. For the moment however you will need to do get the source from the git repository and build it from there, this does take a bit longer as there is more of it!

    Here are the notes that I have made to do this on my own wiki, note that I have made my static version for a 32-bit linux platform (a v-box) so that it will be compatible with my target, so if you want 64-bit just change the relevant options, there are not many:

    How To Compile A Qt Project As A Static Executable

    Part 1 - Linux PC Configuration

    You need to ensure that you have the right tools installed on your PC. These instructions are derived from ​here: "https://wiki.qt.io/Building_Qt_5_from_Git"
    Do the following:

    • Install Ubuntu 14.xx (or higher) 32-bit version. This can be in a Virtual Machine or a fresh PC install.

    • Install Qt and Qt Creator 32-bit from ​http://www.qt.io/download-open-source/
      Select "view all downloads" and then select "Qt 5.x.x for Linux 32-bit". This will download, run it once finished (you may have to chmod a+x this file). Once you have this (and the g++ compiler - see next step) you can build and run dynamic executables, but they won't be portable without dragging around a whole bunch of libraries that you have to go off and find. We also want to be able to generate a static executable.

    • C++ compiler:
      sudo apt-get install g++-multilib

    • qt5 dependencies:
      sudo apt-get build-dep qt5-default

    • Various script languages / installers:
      sudo apt-get install build-essential perl python git

    • X11 windows-system back end
      sudo apt-get install "^libxcb.*" libx11-xcb-dev libglu1-mesa-dev libxrender-dev libxi-dev

    • Libraries for Qt WebKit:
      sudo apt-get install flex bison gperf libicu-dev libxslt-dev ruby

    • Libraries for Qt WebEngine:
      sudo apt-get install libssl-dev libxcursor-dev libxcomposite-dev libxdamage-dev libxrandr-dev libfontconfig1-dev

    • Additional ubuntu 14.04 dependecies (just install them anyway - there are some repeats in here):
      sudo apt-get install libcap-dev libbz2-dev libgcrypt11-dev libpci-dev libnss3-dev build-essential libxcursor-dev libxcomposite-dev libxdamage-dev libxrandr-dev libdrm-dev libfontconfig1-dev libxtst-dev libasound2-dev gperf libcups2-dev libpulse-dev libudev-dev libssl-dev flex bison ruby

    • Libraries for Qt Multimedia:
      sudo apt-get install libasound2-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev

    Part 2 - Install Qt 5.x.x Static Libraries

    To checkout and Compile Static Qt5 Library, follow the steps below:

    • Get the Qt5 source code. You can get this from the ​Qt downloads page (http://www.qt.io/download-open-source/), under Source packages & Other releases click the tar.gz link. The 5.5.0 latest has a bug so it won't compile we are waiting for 5.5.1 (or higher) where the bug is fixed. In the mean time we had to do a git check of Qt 5.5.0 latest branch which includes the fix. This can be done from ​here (https://wiki.qt.io/Building_Qt_5_from_Git):
      git clone git://code.qt.io/qt/qt5.git
      git clone https://code.qt.io/qt/qt5.git

    • Initilise the repository, use the flag "--no-webkit" if you don't want web-kits since its quite large:
      cd qt5
      perl init-repository --no-webkit

    • Configure the project for building. You may not need QT_QML_NO_DEBUGGER or to skip webkit/multimedia, but I found previously that the QT_QML_NO_DEBUGGER was needed to get it to build if you download the sources from the Qt downloads page - it may not be required if you checkout from git (there is A LOT more "stuff").
      ./configure -static -release -nomake examples -nomake tests -skip webkit -skip multimedia -D QT_QML_NO_DEBUGGER

    • Build and Install Qt, I think it defaults to installing in /usr/local/Qt5.5.x
      make -j8
      make install

    This will build the qt version and then you need to create your new kit to point to this new qt version.

  • The 5.5.1 release does not fix the original problem.

    A 64b 5.5.1 static build fails with the same error, just as reported by OP on 5.5.0.

    3.13.0-68-generic #111-Ubuntu SMP Fri Nov 6 18:17:06 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

    Distributor ID: Ubuntu
    Description: Ubuntu 14.04.3 LTS

    gcc (GCC) 4.8.0

    Release: 14.04
    Codename: trusty

  • @habanaro

    I have not yet tested 5.5.1 - I guess it was just released? Well, not sure what happened there, is it possible the fix (which was in the latest code on the git repo) was not included? - that would be very strange.

    So, as mentioned, the other alternative is to build it from the git repo... its a little bit more hassle, but at least you guarantee the fix is there :)

  • I know this is waaaaaaay late from the last post. But I just did a download of the latest released source and can confirm that this is still an issue >.<

    I don't know why the fix has not gone in, it def worked from the latest git checkout.

  • I have similar issue on Ubuntu Linux. I have created a bug report (https://bugreports.qt.io/browse/QTBUG-51282).
    The error message:

    /home/str1/share/Linux/qt-everywhere-opensource-src-5.5.1/qtdeclarative/lib/libQt5Qml.a(qqmldebugserver.o):qqmldebugserver.cpp:function QQmlDebugServerThread::run(): error: undefined reference to 'QTcpServerConnection::QTcpServerConnection()'
    collect2: error: ld returned 1 exit status
    make[4]: *** [chatserver] Error 1
    make[4]: Leaving directory `/home/str1/share/Linux/qt-everywhere-opensource-src-5.5.1/qtwebchannel/examples/webchannel/chatserver-cpp'
    make[3]: *** [sub-chatserver-cpp-install_subtargets] Error 2
    make[3]: Leaving directory `/home/str1/share/Linux/qt-everywhere-opensource-src-5.5.1/qtwebchannel/examples/webchannel'
    make[2]: *** [sub-webchannel-install_subtargets] Error 2
    make[2]: Leaving directory `/home/str1/share/Linux/qt-everywhere-opensource-src-5.5.1/qtwebchannel/examples'
    make[1]: *** [sub-examples-install_subtargets] Error 2
    make[1]: Leaving directory `/home/str1/share/Linux/qt-everywhere-opensource-src-5.5.1/qtwebchannel'

    make: *** [module-qtwebchannel-install_subtargets] Error 2

  • Ah yeah.... good idea to log the bug report, I did not think of that : )

    But still it is strange that it seemed to work on that latest git checkout (at the time this was pre 5.5.1 release) and not in the 5.5.1 release... its like it got fixed but it did not make the 5.5.1 release... hopefully it will be in 5.5.2 (or whatever the next release is)

  • I can confirm similar issue on Mac OS X 10.11.3.
    But successful build was with with flags:
    -nomake examples -nomake tests

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.