c++qtqtcpsocket

C++ Qt - QTcpSocket - File not found


I am using Qt and QTcpSocket to create a small chat client/server application.

When I compile my code, the compiler returns the following error:

main.cpp:3:22: fatal error: QTcpSocket: No such file or directory

This refers to #include <QTcpSocket>.

Where is this library located and how can I install it?


Solution

  • You need

    QT += network
    

    in your .pro file. Otherwise the module in which those headers are defined/libraries are built won't be loaded.