Tôi đã thêm lớp IcecastServer vào dự án QT của mình, thêm tệp tiêu đề vào tệp chuyên nghiệp và thêm một số mã. Mỗi lần tôi biên dịch nó các lỗi sau đây xảy ra:QT lỗi không xác định tham chiếu khi cố gắng biên dịch
phát hành/icecastserver.o:. Icecastserver.cpp :(văn bản + 0x39): tài liệu tham khảo không xác định để
_imp___ZN10QTcpServerC1EP7QObject' release/icecastserver.o:icecastserver.cpp:(.text+0x50): undefined reference to
impZN12QHostAddressC1ENS_14SpecialAddressE' phát hành/icecastserver.o: icecastserver . cpp :(văn bản + 0x68): tài liệu tham khảo không xác định để_imp___ZN10QTcpServer6listenERK12QHostAddresst' release/icecastserver.o:icecastserver.cpp:(.text+0x73): undefined reference to
_imp _ZN12QHostAddressD1Ev ' phát hành/icecastserver.o: icecastserver.cpp :(văn bản + 0x9d):. tài liệu tham khảo không xác định để_imp___ZNK10QTcpServer11errorStringEv' release/icecastserver.o:icecastserver.cpp:(.text+0x3d4): undefined reference to
impZN12QHostAddressD1Ev' phát hành/icecastserver .o: icecastse . Rver.cpp :(văn bản + 0x4bd): tài liệu tham khảo không xác định để_imp___ZN10QTcpServerC1EP7QObject' release/icecastserver.o:icecastserver.cpp:(.text+0x4d4): undefined reference to
_imp _ZN12QHostAddressC1ENS_14SpecialAddressE ' phát hành/icecastserver.o: icecastserver.cpp :(văn bản + 0x4ec):. Tài liệu tham khảo không xác định để_imp___ZN10QTcpServer6listenERK12QHostAddresst' release/icecastserver.o:icecastserver.cpp:(.text+0x4f7): undefined reference to
impZN12QHostAddressD1Ev' phát hành /icecastserver.o: icecastserver.cpp :(văn bản + 0x521):. tài liệu tham khảo không xác định để_imp___ZNK10QTcpServer11errorStringEv' release/icecastserver.o:icecastserver.cpp:(.text+0x858): undefined reference to
_imp _ZN12QHostAddressD1Ev'
tôi đang làm gì sai?
Đây là tiêu đề-file:
#ifndef ICECASTSERVER_H
#define ICECASTSERVER_H
#include <QObject>
QT_BEGIN_NAMESPACE
class QTcpServer;
QT_END_NAMESPACE
class IcecastServer : public QObject
{
Q_OBJECT
public:
explicit IcecastServer(QObject *parent = 0);
signals:
public slots:
private:
QTcpServer *tcpServer;
};
#endif // ICECASTSERVER_H
Đây là nguồn gốc-file:
#include "icecastserver.h"
#include "QDebug"
#include <QtNetwork/QTcpServer>
#include <QtGui>
IcecastServer::IcecastServer(QObject *parent) :
QObject(parent)
{
tcpServer = new QTcpServer(this);
//tcpServer->listen(QHostAddress::Any,8000);
if (!tcpServer->listen()){
QMessageBox::critical(NULL, tr("Fortune Server"), tr("Unable to start the server: %1.").arg(tcpServer->errorString()));
return;
}
}
Tôi đã thêm rằng bao gồm nhưng như bạn đã nói, nhận xét của nó ra, do đó không khắc phục được sự cố. Bạn đang nói đến đầu vào nào? – Hedge
yay! Thêm mạng vào tập tin chuyên nghiệp đã khắc phục sự cố. – Hedge
cho 'QT + = network' tham chiếu có thể được tìm thấy tại https://doc.qt.io/qt-4.8/qmake-variable-reference.html#qt – n611x007