title: Qt : Cannot open include file: 'QtSql': No such file or directory
body: <p>It might be a duplicate question, but the founded answers haven't solved my problem. I am trying to create a client server application in QT where the client sends to the server a String message code and the server has to connect to the sql server database and retrieve data relative to the client's message code.
  Below is the server part I've written so far. But i am getting this error : Cannot open include file: 'QtSql': No such file or directory. When i make separate projects and run the database part, it works perfect, but when i put them together, it fails. 
  Anyone has some suggestions to can solve this problem?</p>
  
  <p>ServerSocket.pro</p>
  
  <pre><code>QT       += core
  QT       += network
  QT       += sql
  QT       -= gui
  
  TARGET = ServerSocket
  CONFIG   += console
  CONFIG   -= app_bundle
  
  TEMPLATE = app
  
  
  SOURCES += main.cpp \
      server.cpp
  
  HEADERS += \
      server.h
  </code></pre>
  
  <p>ServerSocket.h</p>
  
  <pre><code>#ifndef SERVER_H
  #define SERVER_H
  
  #include &lt;QObject&gt;
  #include &lt;QDebug&gt;
  #include &lt;QTcpServer&gt;
  #include &lt;QTcpSocket&gt;
  
  
  class Server : public QObject
  {
      Q_OBJECT
  public:
      explicit Server(QObject *parent = 0);
  
  signals:
  
  public slots:
      void newConnection();
  private:
      QTcpServer *server;
  
  };
  
  #endif // SERVER_H
  </code></pre>
  
  <p>ServerSocket.cpp</p>
  
  <pre><code>#include "server.h"
  #include &lt;QtSql&gt;
  
  Server::Server(QObject *parent) :
      QObject(parent)
  {
      server = new QTcpServer(this);
      connect(server, SIGNAL(newConnection()),this,SLOT(newConnection()));
      if(!server-&gt;listen(QHostAddress::Any,1234)){
          qDebug() &lt;&lt; "Server could not start";
      } else {
          qDebug() &lt;&lt; "Server started";
      }
  }
  void Server::newConnection(){
      QTcpSocket *socket = server-&gt;nextPendingConnection();
      socket-&gt;write("hello client");
      socket-&gt;waitForBytesWritten(1000);
      socket-&gt;waitForReadyRead(1000);
      QString appCode = socket-&gt;readAll();
  
      QString servername = "LOCALHOST\\SQLEXPRESS";
      QString dbname = "ApplicationsDB";
      QString connectionTemplate = "DRIVER={SQL SERVER};SERVER=%1;DATABASE=%2;";
      QSqlQuery query;
      QStringList results;
  
  
      QString connectionString = connectionTemplate.arg(servername).arg(dbname);
      QSqlDatabase db = QSqlDatabase::addDatabase("QODBC");
  
      db.setDatabaseName(connectionString);
  
      if (db.open())
      {
          qDebug() &lt;&lt; "Opened";
          query = db.exec("select Code from Application a where a.Name = '") + appCode + "';";
          while (query.next())
          {
              QString result = query.record().value(0).toString();
              results.append(result);
          }
          for(QString res : results){
              qDebug() &lt;&lt; res;
          }
      }
      else
      {
          qDebug() &lt;&lt; "Error = " &lt;&lt; db.lastError().text();
      }
      db.close();
  }
  </code></pre>