1
votes

Please can someone give me an indication. When I see an error like this in visual studio, I usually know I'm missing a lib. However I'm using qt right out the box so to speak through its own ide. I do not know why QTcpSocket won't build.

mainwindow.obj:: error: unresolved external symbol "__declspec(dllimport) public: virtual _thiscall QTcpSocket::~QTcpSocket(void)" (_imp_??1QTcpSocket@@UAE@XZ) referenced in function "public: virtual __thiscall MainWindow::~MainWindow(void)" (??1MainWindow@@UAE@XZ)

mainwindow.obj:: error: unresolved external symbol "__declspec(dllimport) public: __thiscall QTcpSocket::QTcpSocket(class QObject *)" (_imp??0QTcpSocket@@QAE@PAVQObject@@@Z) referenced in function "public: __thiscall MainWindow::MainWindow(class QWidget *)" (??0MainWindow@@QAE@PAVQWidget@@@Z)

#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QMessageBox>
#include <QtNetwork/QHostAddress>
#include <QtNetwork/QTcpSocket>

namespace Ui {
    class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();

private:
    Ui::MainWindow *ui;

    QTcpSocket sckSock;

private slots:
    void on_pushButton_clicked();

};

#endif // MAINWINDOW_H
1
Are your constructor and destructor actually implemented somewhere?Dan O

1 Answers

5
votes

Inside your .pro file, you should add something like:

QT += network

So the correct libs get linked. See QtNetwork Documentation for more information.