Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Qt sctp problem: Can not define a QSctpSocket/QSctpServer object



  • Hi~
    As following topcis&question says :
    https://forum.qt.io/topic/76065/error-qsctpsocket-does-not-name-a-type-qsctpsocket-t-new-qsctpsocket-please-how-do-we-solve-this-error-or-is-it-qt-5-8-has-this-error

    I meet a similar problem. I can't define a QSctpSocket or QSctpServer object while I'm already added "QT += network" and each header in my project.
    Seems like sctp module not add in Qt. (enviroment: Qt5.12.4, Archlinux)

    As following links says: Cause Qt Sctp not support in Windows platform, so sctp is disabled in Qt.
    https://doc.qt.io/qt-5/qsctpsocket.html#details
    https://stackoverflow.com/questions/49503376/qt-stream-control-transmission-protocol-sctp
    https://stackoverflow.com/questions/56554944/how-to-enable-making-objects-from-qsctpsocket?r=SearchResults

    His solution is add "-stcp" and "-static" flag when configure/compilering Qt. (as folloing command)

    ./configure -sctp
    make 
    make install
    

    But, what about normal version Qt. (I mean installed from repository or Qt Installer. Not installed by compile? What should we do? )

    I'll really appreciate for your help. >.<


  • Lifetime Qt Champion

    @ytexas Well, if SCTP is not implemented in Qt on Windows (as stated here: https://bugreports.qt.io/browse/QTBUG-59282) the only thing you can do is to build Qt by yourself with activated SCTP support.



  • @jsulm
    Thank you :D

    But I'm try to use SCTP on Linux. (Archlinux or Ubuntu) >.<

    I find some official examples about SCTP (multistreamserver & multistreamclient) ( on path Qt/Examples/Qt-5.12.4/network) . But neither of them can be build in Qt Creator. I notice those two examples seems would not be load. Maybe caused by following code in Example's project file (network.pro):

    qtConfig(sctp): SUBDIRS += multistreamserver multistreamclient

  • Lifetime Qt Champion

    @ytexas said in Qt sctp problem: Can not define a QSctpSocket/QSctpServer object:

    But neither of them can be build in Qt Creator

    What happens? Errors?



  • @jsulm

    If load those examples directly ( multistreamserver.pro and multistreamclient.pro). Got compile error when building.

    However, load parent-pro file (network.pro). QtCreator would not load those two sub-project for build & running (edit only).


  • Lifetime Qt Champion

    @ytexas said in Qt sctp problem: Can not define a QSctpSocket/QSctpServer object:

    compile error

    You should post the errors...



  • @jsulm

    Sry. Cause error message is huge.

    For example. Build multistreamserver. Most of errors are invalid use of incomplete type 'class QSctpServer' and invalid use of incomplete type 'class QSctpSocket'

    So it seems Qt didn't have QSctpServer and QSctpcClient.

    Full error message is:

    ../chatprovider.cpp: In member function 'virtual void ChatProvider::readDatagram(QSctpSocket&, const QByteArray&)':
    ../chatprovider.cpp:64:28: error: invalid use of incomplete type 'class QSctpSocket'
       64 |                       .arg(from.peerAddress().toString())
          |                            ^~~~
    In file included from ../chatprovider.h:54,
                     from ../chatprovider.cpp:51:
    ../provider.h:57:7: note: forward declaration of 'class QSctpSocket'
       57 | class QSctpSocket;
          |       ^~~~~~~~~~~
    ../chatprovider.cpp:65:44: error: invalid use of incomplete type 'class QSctpSocket'
       65 |                       .arg(QString::number(from.peerPort()))
          |                                            ^~~~
    In file included from ../chatprovider.h:54,
                     from ../chatprovider.cpp:51:
    ../provider.h:57:7: note: forward declaration of 'class QSctpSocket'
       57 | class QSctpSocket;
          |       ^~~~~~~~~~~
    g++ -c -pipe -O2 -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -Wall -W -D_REENTRANT -fPIC -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -I../../multistreamserver -I. -isystem /usr/include/qt -isystem /usr/include/qt/QtWidgets -isystem /usr/include/qt/QtGui -isystem /usr/include/qt/QtNetwork -isystem /usr/include/qt/QtCore -I. -isystem /usr/include/libdrm -I/usr/lib/qt/mkspecs/linux-g++ -o main.o ../main.cpp
    make: *** [Makefile:1026: chatprovider.o] Error 1
    make: *** Waiting for unfinished jobs....
    ../server.cpp: In constructor 'Server::Server(QWidget*)':
    ../server.cpp:68:38: error: invalid use of incomplete type 'class QSctpServer'
       68 |     sctpServer = new QSctpServer(this);
          |                                      ^
    In file included from ../server.cpp:55:
    ../server.h:59:7: note: forward declaration of 'class QSctpServer'
       59 | class QSctpServer;
          |       ^~~~~~~~~~~
    ../server.cpp:69:15: error: invalid use of incomplete type 'class QSctpServer'
       69 |     sctpServer->setMaximumChannelCount(NumberOfChannels);
          |               ^~
    In file included from ../server.cpp:55:
    ../server.h:59:7: note: forward declaration of 'class QSctpServer'
       59 | class QSctpServer;
          |       ^~~~~~~~~~~
    ../server.cpp:78:39: error: incomplete type 'QSctpServer' used in nested name specifier
       78 |     connect(sctpServer, &QSctpServer::newConnection, this, &Server::newConnection);
          |                                       ^~~~~~~~~~~~~
    ../server.cpp: In member function 'virtual int Server::exec()':
    ../server.cpp:97:20: error: invalid use of incomplete type 'class QSctpServer'
       97 |     if (!sctpServer->listen()) {
          |                    ^~
    In file included from ../server.cpp:55:
    ../server.h:59:7: note: forward declaration of 'class QSctpServer'
       59 | class QSctpServer;
          |       ^~~~~~~~~~~
    ../server.cpp:100:46: error: invalid use of incomplete type 'class QSctpServer'
      100 |                               .arg(sctpServer->errorString()));
          |                                              ^~
    In file included from ../server.cpp:55:
    ../server.h:59:7: note: forward declaration of 'class QSctpServer'
       59 | class QSctpServer;
          |       ^~~~~~~~~~~
    ../server.cpp:119:56: error: invalid use of incomplete type 'class QSctpServer'
      119 |                          .arg(ipAddress).arg(sctpServer->serverPort()));
          |                                                        ^~
    In file included from ../server.cpp:55:
    ../server.h:59:7: note: forward declaration of 'class QSctpServer'
       59 | class QSctpServer;
          |       ^~~~~~~~~~~
    ../server.cpp: In member function 'void Server::newConnection()':
    ../server.cpp:126:41: error: invalid use of incomplete type 'class QSctpServer'
      126 |     QSctpSocket *connection = sctpServer->nextPendingDatagramConnection();
          |                                         ^~
    In file included from ../server.cpp:55:
    ../server.h:59:7: note: forward declaration of 'class QSctpServer'
       59 | class QSctpServer;
          |       ^~~~~~~~~~~
    ../server.cpp:129:39: error: incomplete type 'QSctpSocket' used in nested name specifier
      129 |     connect(connection, &QSctpSocket::channelReadyRead, this, &Server::readDatagram);
          |                                       ^~~~~~~~~~~~~~~~
    ../server.cpp:130:39: error: incomplete type 'QSctpSocket' used in nested name specifier
      130 |     connect(connection, &QSctpSocket::disconnected, this, &Server::clientDisconnected);
          |                                       ^~~~~~~~~~~~
    ../server.cpp: In member function 'void Server::clientDisconnected()':
    ../server.cpp:138:66: error: invalid static_cast from type 'QObject*' to type 'QSctpSocket*'
      138 |     QSctpSocket *connection = static_cast<QSctpSocket *>(sender());
          |                                                                  ^
    In file included from /usr/include/qt/QtNetwork/QtNetwork:31,
                     from ../server.cpp:52:
    /usr/include/qt/QtNetwork/qnetworkdatagram.h:107:18: note: class type 'QSctpSocket' is incomplete
      107 |     friend class QSctpSocket;
          |                  ^~~~~~~~~~~
    ../server.cpp:141:15: error: invalid use of incomplete type 'class QSctpSocket'
      141 |     connection->disconnect();
          |               ^~
    In file included from /usr/include/qt/QtNetwork/QtNetwork:31,
                     from ../server.cpp:52:
    /usr/include/qt/QtNetwork/qnetworkdatagram.h:107:18: note: forward declaration of 'class QSctpSocket'
      107 |     friend class QSctpSocket;
          |                  ^~~~~~~~~~~
    ../server.cpp:146:15: error: invalid use of incomplete type 'class QSctpSocket'
      146 |     connection->deleteLater();
          |               ^~
    In file included from /usr/include/qt/QtNetwork/QtNetwork:31,
                     from ../server.cpp:52:
    /usr/include/qt/QtNetwork/qnetworkdatagram.h:107:18: note: forward declaration of 'class QSctpSocket'
      107 |     friend class QSctpSocket;
          |                  ^~~~~~~~~~~
    ../server.cpp: In member function 'void Server::readDatagram(int)':
    ../server.cpp:151:66: error: invalid static_cast from type 'QObject*' to type 'QSctpSocket*'
      151 |     QSctpSocket *connection = static_cast<QSctpSocket *>(sender());
          |                                                                  ^
    In file included from /usr/include/qt/QtNetwork/QtNetwork:31,
                     from ../server.cpp:52:
    /usr/include/qt/QtNetwork/qnetworkdatagram.h:107:18: note: class type 'QSctpSocket' is incomplete
      107 |     friend class QSctpSocket;
          |                  ^~~~~~~~~~~
    ../server.cpp:153:15: error: invalid use of incomplete type 'class QSctpSocket'
      153 |     connection->setCurrentReadChannel(channel);
          |               ^~
    In file included from /usr/include/qt/QtNetwork/QtNetwork:31,
                     from ../server.cpp:52:
    /usr/include/qt/QtNetwork/qnetworkdatagram.h:107:18: note: forward declaration of 'class QSctpSocket'
      107 |     friend class QSctpSocket;
          |                  ^~~~~~~~~~~
    ../server.cpp:154:61: error: invalid use of incomplete type 'class QSctpSocket'
      154 |     providers[channel]->readDatagram(*connection, connection->readDatagram().data());
          |                                                             ^~
    In file included from /usr/include/qt/QtNetwork/QtNetwork:31,
                     from ../server.cpp:52:
    /usr/include/qt/QtNetwork/qnetworkdatagram.h:107:18: note: forward declaration of 'class QSctpSocket'
      107 |     friend class QSctpSocket;
          |                  ^~~~~~~~~~~
    ../server.cpp: In member function 'void Server::writeDatagram(QSctpSocket*, const QByteArray&)':
    ../server.cpp:162:11: error: invalid use of incomplete type 'class QSctpSocket'
      162 |         to->setCurrentWriteChannel(channel);
          |           ^~
    In file included from /usr/include/qt/QtNetwork/QtNetwork:31,
                     from ../server.cpp:52:
    /usr/include/qt/QtNetwork/qnetworkdatagram.h:107:18: note: forward declaration of 'class QSctpSocket'
      107 |     friend class QSctpSocket;
          |                  ^~~~~~~~~~~
    ../server.cpp:163:11: error: invalid use of incomplete type 'class QSctpSocket'
      163 |         to->writeDatagram(ba);
          |           ^~
    In file included from /usr/include/qt/QtNetwork/QtNetwork:31,
                     from ../server.cpp:52:
    /usr/include/qt/QtNetwork/qnetworkdatagram.h:107:18: note: forward declaration of 'class QSctpSocket'
      107 |     friend class QSctpSocket;
          |                  ^~~~~~~~~~~
    ../server.cpp:168:19: error: invalid use of incomplete type 'class QSctpSocket'
      168 |         connection->setCurrentWriteChannel(channel);
          |                   ^~
    In file included from /usr/include/qt/QtNetwork/QtNetwork:31,
                     from ../server.cpp:52:
    /usr/include/qt/QtNetwork/qnetworkdatagram.h:107:18: note: forward declaration of 'class QSctpSocket'
      107 |     friend class QSctpSocket;
          |                  ^~~~~~~~~~~
    ../server.cpp:169:19: error: invalid use of incomplete type 'class QSctpSocket'
      169 |         connection->writeDatagram(ba);
          |                   ^~
    In file included from /usr/include/qt/QtNetwork/QtNetwork:31,
                     from ../server.cpp:52:
    /usr/include/qt/QtNetwork/qnetworkdatagram.h:107:18: note: forward declaration of 'class QSctpSocket'
      107 |     friend class QSctpSocket;
          |                  ^~~~~~~~~~~
    In file included from /usr/include/qt/QtCore/QtCore:4,
                     from /usr/include/qt/QtWidgets/QtWidgetsDepends:3,
                     from /usr/include/qt/QtWidgets/QtWidgets:3,
                     from ../server.cpp:51:
    /usr/include/qt/QtCore/qmetatype.h: In instantiation of 'struct QtPrivate::IsPointerToTypeDerivedFromQObject<QSctpSocket*>':
    /usr/include/qt/QtCore/qmetatype.h:1643:60:   required from 'struct QMetaTypeId<QSctpSocket*>'
    /usr/include/qt/QtCore/qmetatype.h:1662:10:   required from 'struct QMetaTypeId2<QSctpSocket*>'
    /usr/include/qt/QtCore/qobject_impl.h:68:49:   required from 'struct QtPrivate::TypesAreDeclaredMetaType<QtPrivate::List<QSctpSocket*, const QByteArray&> >'
    /usr/include/qt/QtCore/qobject.h:251:86:   required from 'static QMetaObject::Connection QObject::connect(const typename QtPrivate::FunctionPointer<Func>::Object*, Func1, const typename QtPrivate::FunctionPointer<Func2>::Object*, Func2, Qt::ConnectionType) [with Func1 = void (Provider::*)(QSctpSocket*, const QByteArray&); Func2 = void (Server::*)(QSctpSocket*, const QByteArray&); typename QtPrivate::FunctionPointer<Func>::Object = Provider; typename QtPrivate::FunctionPointer<Func2>::Object = Server]'
    ../server.cpp:80:99:   required from here
    /usr/include/qt/QtCore/qmetatype.h:1415:9: error: invalid application of 'sizeof' to incomplete type 'QSctpSocket'
     1415 |         Q_STATIC_ASSERT_X(sizeof(T), "Type argument of Q_DECLARE_METATYPE(T*) must be fully defined");
          |         ^~~~~~~~~~~~~~~~~
    make: *** [Makefile:1014: server.o] Error 1
    
    

    Thanks for attention so much >.<


  • Lifetime Qt Champion

    @ytexas Same for me. Probably Qt was build without support for SCTP.
    I see this in qsctpsocket.h:

    #if !defined(QT_NO_SCTP) || defined(Q_CLANG_QDOC)
    

    My guess is you need to build Qt by yourself and activate SCTP support.



  • @jsulm
    Thank you so much. xD
    So, current situation is: official releases 's SCTP is unavailable. Build Qt from source is only solution. TuT


  • Lifetime Qt Champion

    @ytexas Looks like this, yes. I don't know why SCTP is not built in official releases, maybe it's considered not stable enough.


Log in to reply