C++ Qt - QTcpSocket - File not found

Béatrice Moissinac picture Béatrice Moissinac · Nov 5, 2012 · Viewed 13.5k times · Source

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?

Answer

Matt Phillips picture Matt Phillips · Nov 5, 2012

You need

QT += network

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