Important: Please read the Qt Code of Conduct -

How to compile Qt5Websockets and install it on my Qt folder installation?

  • It appears that libwebsocket is the only library that does not come with Qt (WHY????), so I think I need to compile it and install it in my QT folder so I can use with other things.

    I tried to compile libwebsocket and I got this error:

    qwebsocket_p.h:65:10: fatal error: private/qobject_p.h: No such file or directory
     #include <private/qobject_p.h>

    I believe this is because the QT in my system is old. I have a QT installation in my home folder. How should I pass it to websocket?

    If it were with cmake I'd have an idea, but I've heard here that you cannot pass qt folder to qmake. Is there a way to pass to make?

    I also tried doing this in cmake:

    find_package(Qt5WebSockets REQUIRED)
    find_package(Qt5 COMPONENTS Core Qml Quick Svg)

    this way I can do cmake -DQt5_DIR=/home/lz/Qt5.11.2 . to set the Qt5 variable for everything except Qt5WebSockets, but the project fails to include <QWebSocket> anyway. If someone knows how to solve this, it'd also be good

  • @lucaszanella

    Did you add QT += core websockets to your pro file?

  • I forgot to mention that my project is strictly cmake, there are no pro files

  • @lucaszanella
    What version of Qt? and on what platform?

  • @Ratzz I just installed Qt5.11.2 on my home folder on Ubuntu and I'm doing

    cmake -DQt5_DIR=/home/lz/Qt5.11.2 .

    to force cmake to use it. But since it doesn't come with websockets I'm having problems

  • @lucaszanella
    Can you try sudo apt-get install libqt5websockets5-dev
    or try to build it

  • Lifetime Qt Champion

    @Ratzz said in How to compile Qt5Websockets and install it on my Qt folder installation?:

    Can you try sudo apt-get install libqt5websockets5-dev

    He uses custom Qt installation, installing Qt packages from Ubuntu will not help

  • @Ratzz I tried to build from source, but I think since my QT on computer (not the on on the home folder) is old, I have the error I mentioned in my first post. So I think I have to find a way to compile the websockets library using the QT on the home folder

  • @lucaszanella
    How many versions of Qt is installed in system?
    What is that old Qt mean?

  • @Ratzz I have Qt 5.12.1 installed on my home folder, and the Qt from Ubuntu instaled on the system, which is 5.3. I want to compile libwebsockets using the Qt 5.12.1

  • Lifetime Qt Champion

    @lucaszanella so how did you install Qt 5.12.1?

    And how did you check that you don't have websockets?

    I really doubt that websockets are missing, since they will be installed by only and offline installer always.

    The only exception is the distributions package manager, where you may be able to install them separate.


  • Lifetime Qt Champion


    regarding the question:

    Is there a way to pass to make?

    Each Qt version has it's own qmake, so by choosing qmake (with full path) you choose the Qt version you wanne use.


  • @aha_1980 because the project im compiling compiles lots of files that use Qt, but the only problem happens on QtWebsocket. Strangely enough, /home/lz/Qt5.11.2/5.11.2/gcc_64/lib do indeed contain libwebsockets.

    Does that output mean anything to you?

    [ 30%] Building CXX object react-native-desktop-orwell/ReactQt/runtime/src/CMakeFiles/react-native.dir/websocketmodule.cpp.o
    cd /home/lz/orwell/react-native-desktop-orwell/ReactQt/runtime/src && /usr/bin/c++  -DQT_CORE_LIB -DQT_GUI_LIB -DQT_MULTIMEDIAWIDGETS_LIB -DQT_MULTIMEDIA_LIB -DQT_NETWORK_LIB -DQT_NO_DEBUG -DQT_QML_LIB -DQT_QUICK_LIB -DQT_WIDGETS_LIB -Dreact_native_EXPORTS -I/home/lz/orwell/react-native-desktop-orwell/ReactQt/runtime/src -I/home/lz/orwell/react-native-desktop-orwell/ReactQt/runtime/src/react-native_autogen/include -I/home/lz/orwell/react-native-desktop-orwell/./React/Layout -I/home/lz/orwell/react-native-desktop-orwell/ReactQt/runtime/src/../../../../myRtspClient/third_party/Base64_live555/include -I/home/lz/orwell/react-native-desktop-orwell/ReactQt/runtime/src/../../../../myRtspClient/third_party/md5/include -I/home/lz/orwell/react-native-desktop-orwell/ReactQt/runtime/src/../../../../myRtspClient/third_party/JRTPLIB/src -I/home/lz/orwell/react-native-desktop-orwell/ReactQt/runtime/src/../../../../myRtspClient/include -I/home/lz/orwell/react-native-desktop-orwell/ReactQt/runtime/src/../../../../myRtspClient/myRtspClient/include -I/home/lz/orwell/react-native-desktop-orwell/ReactQt/runtime/src/../../../../myRtspClient/third_party/JTHREAD/src -I/home/lz/orwell/react-native-desktop-orwell/ReactQt/runtime/src/../../../.. -I/home/lz/orwell/react-native-desktop-orwell/ReactQt/runtime/src/jrtplib/src -isystem /home/lz/Qt5.11.2/5.11.2/gcc_64/include -isystem /home/lz/Qt5.11.2/5.11.2/gcc_64/include/QtWidgets -isystem /home/lz/Qt5.11.2/5.11.2/gcc_64/include/QtGui -isystem /home/lz/Qt5.11.2/5.11.2/gcc_64/include/QtCore -isystem /home/lz/Qt5.11.2/5.11.2/gcc_64/./mkspecs/linux-g++ -isystem /home/lz/Qt5.11.2/5.11.2/gcc_64/include/QtMultimedia -isystem /home/lz/Qt5.11.2/5.11.2/gcc_64/include/QtNetwork -isystem /home/lz/Qt5.11.2/5.11.2/gcc_64/include/QtMultimediaWidgets -isystem /home/lz/Qt5.11.2/5.11.2/gcc_64/include/QtQml -isystem /home/lz/Qt5.11.2/5.11.2/gcc_64/include/QtQuick  -std=c++11 -fPIC   -fPIC -std=gnu++11 -o CMakeFiles/react-native.dir/websocketmodule.cpp.o -c /home/lz/orwell/react-native-desktop-orwell/ReactQt/runtime/src/websocketmodule.cpp
    /home/lz/orwell/react-native-desktop-orwell/ReactQt/runtime/src/websocketmodule.cpp:12:10: fatal error: QWebSocket: No such file or directory
     #include <QWebSocket>

  • Lifetime Qt Champion


    In qmake, you would have to add QT += websockets to your .pro file. I really don't know how the CMake equivalent is. already discusses this topic, but has not been marked as SOLVED. Therefore I don't know if the solution has been found.

Log in to reply