You need
QT += network
in your .pro file. Otherwise the module in which those headers are defined/libraries are built won't be loaded.
Вопрос
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?
Решение
You need
QT += network
in your .pro file. Otherwise the module in which those headers are defined/libraries are built won't be loaded.
Другие советы
As I faced the problem and the obvious solution proposed by the documentation and Matt Phillips seemed not to work, I would add to check ALL your .pro files of all your potential subprojects.
As far I'm concerned, addind QT *= network
did not work in the main .pro and had to be put in the one actually using the QTcpSocket and QTcpServer objects.