我在使用QUdpSocket出现了很奇怪的问题
相关代码如下:
#include <QMessageBox>
#include <QtNetwork/QUdpSocket>
 #include <QtNetwork/QHostAddress>
#include "ui_server.h"
class server: public QMainWindow
{Q_OBJECT
 public: server(QWidget *parent = 0);
private slots:
        void about();
        void sendmsg();
private:
        Ui::ServerMainWindow ui;
        QUdpSocket *udpSocket;
};
server::server(QWidget *parent):QMainWindow(parent)
{
udpSocket = new QUdpSocket(this);
    ui.setupUi(this);
 connect(ui.aboutAction, SIGNAL(triggered()), this, SLOT(about()));
connect(ui.SendmsgButton,SIGNAL(clicked()),this,SLOT(sendmsg()));
}
结果编译无法通过,错误信息:
 
D:/project/server/server.cpp:5: undefined reference to `_imp___ZN10QUdpSocketC1EP7QObject'
D:/project/server/server.cpp:5: undefined reference to `_imp___ZN10QUdpSocketC1EP7QObject'
:-1: error: collect2: ld returned 1 exit status
 
报错的代码就是
udpSocket = new QUdpSocket(this);
 
我用的windows下的qt creator