QString :: fromUtf8和未定义引用的多重定义

时间:2014-04-30 07:01:24

标签: c++ qt undefined-reference multiple-definition-error migrating

我正在将一个巨大的项目从Qt4.x迁移到Qt5。现在我遇到了这个我无法解决的问题:

C:\Qt5\5.2.1\mingw48_32\lib/libQt5Core.a(d003170.o):(.text+0x0): multiple definition of `QString::fromUtf8(char const*, int)'
./release\aisinfowidget.o:aisinfowidget.cpp:(.text$_ZN7QString8fromUtf8EPKci[__ZN7QString8fromUtf8EPKci]+0x0): first defined here
./release\gpssettingswidget.o:gpssettingswidget.cpp:(.text+0x4dcc): undefined reference to `QtAddOn::SerialPort::SerialPortInfo::availablePorts()'
./release\gpssettingswidget.o:gpssettingswidget.cpp:(.text+0x4e3e): undefined reference to `QtAddOn::SerialPort::SerialPortInfo::portName() const'
./release\gpssettingswidget.o:gpssettingswidget.cpp:(.text+0x4e5d): undefined reference to `QtAddOn::SerialPort::SerialPortInfo::description() const'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: ./release\gpssettingswidget.o: bad reloc address 0xd in section `.text$_ZN25Ui_GPSSettingsWidgetClass13retranslateUiEP14SettingsWidget[__ZN25Ui_GPSSettingsWidgetClass13retranslateUiEP14SettingsWidget]'
collect2.exe: error: ld returned 1 exit status

我知道必须有一些包含重复,但项目是如此巨大我不知道如何找到它,奇怪的是QString,因为它默认添加我认为,你不必做任何包含或任何事情。我在网上搜索了同样的问题,但显然没有任何关于它。 这是包括:

aisinfowidget.cpp:

#include "aisinfowidget.h"
#include "appcommon.h"
#include "shipdata.h"
#include "messagebox.h"
#include "touchswibz.h"
#include "customwidgets.h"
#include "riskwidget.h"
#include "aisradarmodule.h"
#include "mapmodulelist.h"
#include "eventswidget.h"

#include <HDP.h>

#include <QTextTable>
#include <QDesktopServices>
#include <QUuid>
#include <QUrlQuery>

gpssettingswidget.cpp (从这里来看未定义的引用)

#include "gpssettingswidget.h"
#include "gpsmodule.h"

#include <QtSerialPort/QSerialPort>
#include <QtSerialPort/QSerialPortInfo>
#include "QtSerialPort/qserialportglobal.h"
#include "QtSerialPort/qserialportinfo.h"
//#include <qextserialenumerator.h>

#include <QLineEdit>
#include <QtDebug>

这是我的 .pro 文件:

TEMPLATE = app
TARGET = Swibz
include(Swibz.pri)
DESTDIR = ../Release
QT += widgets network xml webkit webkitwidgets opengl serialport #core gui are by default
CONFIG += release
DEFINES += _WINDOWS QT_LARGEFILE_SUPPORT QT_XML_LIB QT_OPENGL_LIB QT_NETWORK_LIB QT_DLL QWT_DLL JSON_LIB_LIB
INCLUDEPATH += ../../../SprintLib \
    ./GeneratedFiles \
    ./GeneratedFiles/Release \
    . \
    ../qwt/src \
    ../qenc \
    ../zlib-1.2.5 \
    ../qextserialport-1.2win-alpha \
    ../qxmpp/qxmpp-master/base \
    ../qxmpp/qxmpp-master/client \
    ../qxmpp/qxmpp-master/server \
    .\qxmpp-0.3.1\src \
    ../json/JSON \
    ../QtSerialPort/qtserialport/include
LIBS += -L"../../../SprintLib/release" \
    -lopengl32 \
    -lglu32 \
    -lgdi32 \
    -luser32 \
    -l:"C:/Users/Sprint/Desktop/swe/marssies/zlib1.dll" \
    -l:"C:/Users/Sprint/Desktop/swe/marssies/libqwt.a" \
    -l:"C:/Users/Sprint/Desktop/swe/marssies/libHDP.a" \
    -l:"C:/Users/Sprint/Desktop/swe/marssies/libqextserialportd.a" \
    -l:"C:/Users/Sprint/Desktop/swe/marssies/libjson_lib.a" \
    -l:"C:/Users/Sprint/Desktop/swe/marssies/libQtSerialPortd.a" \ ##conflict
    -l:"C:/Users/Sprint/Desktop/swe/marssies/QENC.dll" \
    -l:"C:/Users/Sprint/Desktop/swe/marssies/libQxtNetwork.a" \
    -lsetupapi \
    -l:"C:/Users/Sprint/Desktop/swe/marssies/libqxmpp_d.a" \

TRANSLATIONS = ln_en.ts
TRANSLATIONS = ln_lv.ts
TRANSLATIONS = ln_lt.ts
TRANSLATIONS = ln_es.ts

CODECFORTR     = UTF-8

正如您所看到的,我已将serialport添加到QT变量并且我已链接库,因此我不知道为什么未定义的引用。也许解决QString的多重定义将解决这些问题。 我希望有人能指出我正确的方向。

非常感谢。

P.S:代码不是我的,这使得找到问题变得更加困难。

编辑

我已尝试评论与库的链接以及gpssettingswidget.cpp中的所有包含并获取相同的未定义引用错误,因此我必须遗漏某些内容,但是什么?它仍然可能是多重定义错误。直到我解决了那个,我无法确定其他人。

编辑2

显然,根据Qt5中的this,只需要添加

#include <QtSerialPort/QtSerialPort> 
文件中的

和.pro文件中的QT + = serialport,但即使这样做我也会得到相同的错误。我确信编译器在某种程度上无法找到库,但我不知道还能做什么。我也不知道是否应该使用Qt4或Qt5编译的库。我试了两次,一遍又一遍地犯同样的错误。

编辑3好!

我设法解决了错误,在以千种不同的方式编译QtSerialPort后,我得到了一个解决了未定义引用的文件,虽然现在我得到了所有这些错误,所以我不确定如果它向前或向后一步**

C:\Qt5\5.2.1\mingw48_32\lib/libQt5Core.a(d003170.o):(.text+0x0): multiple definition of `QString::fromUtf8(char const*, int)'
./release\aisinfowidget.o:aisinfowidget.cpp:(.text$_ZN7QString8fromUtf8EPKci[__ZN7QString8fromUtf8EPKci]+0x0): first defined here
./release\main.o:main.cpp:(.text+0x77a4): undefined reference to `QWindowsStyle::QWindowsStyle()'
C:/Users/Sprint/Desktop/swe/marssies/libqxmpp_d.a(moc_QXmppMucManager.o):moc_QXmppMucManager.cpp:(.rdata$_ZTV15QXmppMucManager[__ZTV15QXmppMucManager]+0x30): undefined reference to `QObject::connectNotify(char const*)'
C:/Users/Sprint/Desktop/swe/marssies/libqxmpp_d.a(moc_QXmppMucManager.o):moc_QXmppMucManager.cpp:(.rdata$_ZTV15QXmppMucManager[__ZTV15QXmppMucManager]+0x34): undefined reference to `QObject::disconnectNotify(char const*)'
Makefile.Release:922: recipe for target '..\Release\Swibz.exe' failed
C:/Users/Sprint/Desktop/swe/marssies/libqxmpp_d.a(moc_QXmppMucManager.o): In function `ZN4QMapI7QStringS0_E8freeDataEP8QMapData':
c:/Qt/4.8.5/include/QtCore/../../src/corelib/tools/qmap.h:655: undefined reference to `_imp___ZN8QMapData16continueFreeDataEi'
C:/Users/Sprint/Desktop/swe/marssies/libqxmpp_d.a(moc_QXmppMucManager.o): In function `ZN4QMapI7QStringS_IS0_13QXmppPresenceEE8freeDataEP8QMapData':
c:/Qt/4.8.5/include/QtCore/../../src/corelib/tools/qmap.h:655: undefined reference to `_imp___ZN8QMapData16continueFreeDataEi'
C:/Users/Sprint/Desktop/swe/marssies/libqxmpp_d.a(moc_QXmppMucManager.o): In function `ZN4QMapI7QString13QXmppPresenceE8freeDataEP8QMapData':
c:/Qt/4.8.5/include/QtCore/../../src/corelib/tools/qmap.h:655: undefined reference to `_imp___ZN8QMapData16continueFreeDataEi'
C:/Users/Sprint/Desktop/swe/marssies/libqxmpp_d.a(QXmppRosterManager.o): In function `ZN18QXmppRosterManager12handleStanzaERK11QDomElement':
C:\Users\Sprint\Desktop\swe\marssies\qxmpp-0.3.1\build-src-Qt_4_8_5-Debug/../src/QXmppRosterManager.cpp:80: undefined reference to `_imp___ZNK7QStringeqERKS_'
C:/Users/Sprint/Desktop/swe/marssies/libqxmpp_d.a(QXmppRosterManager.o): In function `ZN18QXmppRosterManager16rosterIqReceivedERK13QXmppRosterIq':
C:\Users\Sprint\Desktop\swe\marssies\qxmpp-0.3.1\build-src-Qt_4_8_5-Debug/../src/QXmppRosterManager.cpp:150: undefined reference to `_imp___ZNK7QStringeqERKS_'
C:/Users/Sprint/Desktop/swe/marssies/libqxmpp_d.a(QXmppRosterManager.o): In function `ZN7QStringC1Ev':
c:/Qt/4.8.5/include/QtCore/../../src/corelib/tools/qstring.h:879: undefined reference to `_imp___ZN7QString11shared_nullE'
C:/Users/Sprint/Desktop/swe/marssies/libqxmpp_d.a(QXmppRosterManager.o): In function `Z23qStringComparisonHelperRK7QStringPKc':
c:/Qt/4.8.5/include/QtCore/../../src/corelib/tools/qstring.h:919: undefined reference to `_imp___ZN7QString16codecForCStringsE'
c:/Qt/4.8.5/include/QtCore/../../src/corelib/tools/qstring.h:919: undefined reference to `_imp___ZN7QString9fromAsciiEPKci'
c:/Qt/4.8.5/include/QtCore/../../src/corelib/tools/qstring.h:919: undefined reference to `_imp___ZNK7QStringeqERKS_'
c:/Qt/4.8.5/include/QtCore/../../src/corelib/tools/qstring.h:921: undefined reference to `_imp___ZNK7QStringeqERK13QLatin1String'
C:/Users/Sprint/Desktop/swe/marssies/libqxmpp_d.a(QXmppRosterManager.o): In function `ZN4QMapI7QStringN13QXmppRosterIq4ItemEEC1Ev':
c:/Qt/4.8.5/include/QtCore/../../src/corelib/tools/qmap.h:182: undefined reference to `_imp___ZN8QMapData11shared_nullE'
C:/Users/Sprint/Desktop/swe/marssies/libqxmpp_d.a(QXmppRosterManager.o): In function `ZN4QMapI7QStringS_IS0_13QXmppPresenceEEC1Ev':
c:/Qt/4.8.5/include/QtCore/../../src/corelib/tools/qmap.h:182: undefined reference to `_imp___ZN8QMapData11shared_nullE'
C:/Users/Sprint/Desktop/swe/marssies/libqxmpp_d.a(QXmppRosterManager.o): In function `ZN4QMapI7QString13QXmppPresenceE6removeERKS0_':
c:/Qt/4.8.5/include/QtCore/../../src/corelib/tools/qmap.h:685: undefined reference to `_imp___ZN8QMapData11node_deleteEPPNS_4NodeEiS1_'
C:/Users/Sprint/Desktop/swe/marssies/libqxmpp_d.a(QXmppRosterManager.o): In function `ZN4QMapI7QString13QXmppPresenceEC1Ev':
c:/Qt/4.8.5/include/QtCore/../../src/corelib/tools/qmap.h:182: undefined reference to `_imp___ZN8QMapData11shared_nullE'
C:/Users/Sprint/Desktop/swe/marssies/libqxmpp_d.a(QXmppRosterManager.o): In function `ZN4QMapI7QStringN13QXmppRosterIq4ItemEE8freeDataEP8QMapData':
c:/Qt/4.8.5/include/QtCore/../../src/corelib/tools/qmap.h:655: undefined reference to `_imp___ZN8QMapData16continueFreeDataEi'
C:/Users/Sprint/Desktop/swe/marssies/libqxmpp_d.a(QXmppRosterManager.o): In function `ZN4QMapI7QStringS_IS0_13QXmppPresenceEE11node_createEP8QMapDataPPNS4_4NodeERKS0_RKS2_':
c:/Qt/4.8.5/include/QtCore/../../src/corelib/tools/qmap.h:453: undefined reference to `_imp___ZN8QMapData11node_createEPPNS_4NodeEii'
c:/Qt/4.8.5/include/QtCore/../../src/corelib/tools/qmap.h:464: undefined reference to `_imp___ZN8QMapData11node_deleteEPPNS_4NodeEiS1_'
C:/Users/Sprint/Desktop/swe/marssies/libqxmpp_d.a(QXmppRosterManager.o): In function `ZN4QMapI7QString13QXmppPresenceE11node_createEP8QMapDataPPNS3_4NodeERKS0_RKS1_':
c:/Qt/4.8.5/include/QtCore/../../src/corelib/tools/qmap.h:453: undefined reference to `_imp___ZN8QMapData11node_createEPPNS_4NodeEii'
c:/Qt/4.8.5/include/QtCore/../../src/corelib/tools/qmap.h:464: undefined reference to `_imp___ZN8QMapData11node_deleteEPPNS_4NodeEiS1_'
C:/Users/Sprint/Desktop/swe/marssies/libqxmpp_d.a(QXmppRosterManager.o): In function `Z15qMapLessThanKeyI7QStringEbRKT_S3_':
c:/Qt/4.8.5/include/QtCore/../../src/corelib/tools/qmap.h:107: undefined reference to `_imp___ZNK7QStringltERKS_'
C:/Users/Sprint/Desktop/swe/marssies/libqxmpp_d.a(QXmppRosterManager.o): In function `ZN4QMapI7QStringN13QXmppRosterIq4ItemEE11node_createEP8QMapDataPPNS4_4NodeERKS0_RKS2_':
c:/Qt/4.8.5/include/QtCore/../../src/corelib/tools/qmap.h:453: undefined reference to `_imp___ZN8QMapData11node_createEPPNS_4NodeEii'
c:/Qt/4.8.5/include/QtCore/../../src/corelib/tools/qmap.h:464: undefined reference to `_imp___ZN8QMapData11node_deleteEPPNS_4NodeEiS1_'
C:/Users/Sprint/Desktop/swe/marssies/libqxmpp_d.a(QXmppRosterManager.o): In function `ZN4QMapI7QStringN13QXmppRosterIq4ItemEE13detach_helperEv':
c:/Qt/4.8.5/include/QtCore/../../src/corelib/tools/qmap.h:755: undefined reference to `_imp___ZN8QMapData10createDataEi'
C:/Users/Sprint/Desktop/swe/marssies/libqxmpp_d.a(QXmppRosterManager.o): In function `ZN4QMapI7QStringS_IS0_13QXmppPresenceEE13detach_helperEv':
c:/Qt/4.8.5/include/QtCore/../../src/corelib/tools/qmap.h:755: undefined reference to `_imp___ZN8QMapData10createDataEi'
C:/Users/Sprint/Desktop/swe/marssies/libqxmpp_d.a(QXmppRosterManager.o): In function `ZN4QMapI7QString13QXmppPresenceE13detach_helperEv':
c:/Qt/4.8.5/include/QtCore/../../src/corelib/tools/qmap.h:755: undefined reference to `_imp___ZN8QMapData10createDataEi'
C:/Users/Sprint/Desktop/swe/marssies/libqxmpp_d.a(QXmppPresence.o): In function `ZN13QXmppPresence5parseERK11QDomElement':
C:\Users\Sprint\Desktop\swe\marssies\qxmpp-0.3.1\build-src-Qt_4_8_5-Debug/../src/QXmppPresence.cpp:116: undefined reference to `_imp___ZNK7QString7toAsciiEv'
C:\Users\Sprint\Desktop\swe\marssies\qxmpp-0.3.1\build-src-Qt_4_8_5-Debug/../src/QXmppPresence.cpp:132: undefined reference to `_imp___ZNK7QString7toAsciiEv'
C:/Users/Sprint/Desktop/swe/marssies/libqxmpp_d.a(QXmppPresence.o): In function `ZNK13QXmppPresence10getTypeStrEv':
C:\Users\Sprint\Desktop\swe\marssies\qxmpp-0.3.1\build-src-Qt_4_8_5-Debug/../src/QXmppPresence.cpp:239: undefined reference to `_imp___Z8qWarningPKcz'
C:/Users/Sprint/Desktop/swe/marssies/libqxmpp_d.a(QXmppPresence.o): In function `ZN13QXmppPresence14setTypeFromStrERK7QString':
C:\Users\Sprint\Desktop\swe\marssies\qxmpp-0.3.1\build-src-Qt_4_8_5-Debug/../src/QXmppPresence.cpp:300: undefined reference to `_imp___Z8qWarningPKcz'
C:/Users/Sprint/Desktop/swe/marssies/libqxmpp_d.a(QXmppPresence.o): In function `ZN13QXmppPresence6Status14setTypeFromStrERK7QString':
C:\Users\Sprint\Desktop\swe\marssies\qxmpp-0.3.1\build-src-Qt_4_8_5-Debug/../src/QXmppPresence.cpp:368: undefined reference to `_imp___Z8qWarningPKcz'
C:/Users/Sprint/Desktop/swe/marssies/libqxmpp_d.a(QXmppPresence.o): In function `ZNK13QXmppPresence6Status10getTypeStrEv':
C:\Users\Sprint\Desktop\swe\marssies\qxmpp-0.3.1\build-src-Qt_4_8_5-Debug/../src/QXmppPresence.cpp:399: undefined reference to `_imp___Z8qWarningPKcz'
C:/Users/Sprint/Desktop/swe/marssies/libqxmpp_d.a(QXmppPresence.o): In function `ZN10QByteArrayC1Ev':
c:/Qt/4.8.5/include/QtCore/../../src/corelib/tools/qbytearray.h:400: undefined reference to `_imp___ZN10QByteArray11shared_nullE'
C:/Users/Sprint/Desktop/swe/marssies/libqxmpp_d.a(QXmppClient.o): In function `ZN11QXmppClient12addExtensionEP20QXmppClientExtension':
C:\Users\Sprint\Desktop\swe\marssies\qxmpp-0.3.1\build-src-Qt_4_8_5-Debug/../src/QXmppClient.cpp:213: undefined reference to `_imp___Z8qWarningPKcz'
C:/Users/Sprint/Desktop/swe/marssies/libqxmpp_d.a(QXmppClient.o): In function `ZN11QXmppClient15removeExtensionEP20QXmppClientExtension':
C:\Users\Sprint\Desktop\swe\marssies\qxmpp-0.3.1\build-src-Qt_4_8_5-Debug/../src/QXmppClient.cpp:236: undefined reference to `_imp___Z8qWarningPKcz'
C:/Users/Sprint/Desktop/swe/marssies/libqxmpp_d.a(QXmppMucManager.o): In function `ZN15QXmppMucManager11sendMessageERK7QStringS2_':
C:\Users\Sprint\Desktop\swe\marssies\qxmpp-0.3.1\build-src-Qt_4_8_5-Debug/../src/QXmppMucManager.cpp:251: undefined reference to `_imp___Z8qWarningPKcz'
C:/Users/Sprint/Desktop/swe/marssies/libqxmpp_d.a(QXmppMucManager.o): In function `ZN4QMapI7QStringS0_E4takeERKS0_':
c:/Qt/4.8.5/include/QtCore/../../src/corelib/tools/qmap.h:710: undefined reference to `_imp___ZN8QMapData11node_deleteEPPNS_4NodeEiS1_'
C:/Users/Sprint/Desktop/swe/marssies/libqxmpp_d.a(QXmppMucManager.o): In function `ZN4QMapI7QStringS0_E11node_createEP8QMapDataPPNS2_4NodeERKS0_S8_':
c:/Qt/4.8.5/include/QtCore/../../src/corelib/tools/qmap.h:453: undefined reference to `_imp___ZN8QMapData11node_createEPPNS_4NodeEii'
c:/Qt/4.8.5/include/QtCore/../../src/corelib/tools/qmap.h:464: undefined reference to `_imp___ZN8QMapData11node_deleteEPPNS_4NodeEiS1_'
C:/Users/Sprint/Desktop/swe/marssies/libqxmpp_d.a(QXmppMessage.o): In function `ZNK12QXmppMessage10getTypeStrEv':
C:\Users\Sprint\Desktop\swe\marssies\qxmpp-0.3.1\build-src-Qt_4_8_5-Debug/../src/QXmppMessage.cpp:104: undefined reference to `_imp___Z8qWarningPKcz'
C:/Users/Sprint/Desktop/swe/marssies/libqxmpp_d.a(QXmppMessage.o): In function `ZN12QXmppMessage14setTypeFromStrERK7QString':
C:\Users\Sprint\Desktop\swe\marssies\qxmpp-0.3.1\build-src-Qt_4_8_5-Debug/../src/QXmppMessage.cpp:154: undefined reference to `_imp___Z8qWarningPKcz'
C:/Users/Sprint/Desktop/swe/marssies/libqxmpp_d.a(QXmppElement.o): In function `ZNK12QXmppElement17firstChildElementERK7QString':
C:\Users\Sprint\Desktop\swe\marssies\qxmpp-0.3.1\build-src-Qt_4_8_5-Debug/../src/QXmppElement.cpp:158: undefined reference to `_imp___ZNK7QStringeqERKS_'
C:/Users/Sprint/Desktop/swe/marssies/libqxmpp_d.a(QXmppElement.o): In function `ZNK12QXmppElement18nextSiblingElementERK7QString':
C:\Users\Sprint\Desktop\swe\marssies\qxmpp-0.3.1\build-src-Qt_4_8_5-Debug/../src/QXmppElement.cpp:169: undefined reference to `_imp___ZNK7QStringeqERKS_'
C:/Users/Sprint/Desktop/swe/marssies/libqxmpp_d.a(QXmppElement.o): In function `ZNK7QStringneERKS_':
c:/Qt/4.8.5/include/QtCore/../../src/corelib/tools/qstring.h:406: undefined reference to `_imp___ZNK7QStringeqERKS_'
C:/Users/Sprint/Desktop/swe/marssies/libqxmpp_d.a(QXmppElement.o): In function `ZN4QMapI7QStringS0_EC1Ev':
c:/Qt/4.8.5/include/QtCore/../../src/corelib/tools/qmap.h:182: undefined reference to `_imp___ZN8QMapData11shared_nullE'
C:/Users/Sprint/Desktop/swe/marssies/libqxmpp_d.a(QXmppDiscoveryIq.o): In function `identityLessThan':
C:\Users\Sprint\Desktop\swe\marssies\qxmpp-0.3.1\build-src-Qt_4_8_5-Debug/../src/QXmppDiscoveryIq.cpp:33: undefined reference to `_imp___ZNK7QStringltERKS_'
C:\Users\Sprint\Desktop\swe\marssies\qxmpp-0.3.1\build-src-Qt_4_8_5-Debug/../src/QXmppDiscoveryIq.cpp:38: undefined reference to `_imp___ZNK7QStringltERKS_'
C:\Users\Sprint\Desktop\swe\marssies\qxmpp-0.3.1\build-src-Qt_4_8_5-Debug/../src/QXmppDiscoveryIq.cpp:43: undefined reference to `_imp___ZNK7QStringltERKS_'
C:\Users\Sprint\Desktop\swe\marssies\qxmpp-0.3.1\build-src-Qt_4_8_5-Debug/../src/QXmppDiscoveryIq.cpp:48: undefined reference to `_imp___ZNK7QStringltERKS_'
C:/Users/Sprint/Desktop/swe/marssies/libqxmpp_d.a(QXmppDiscoveryIq.o): In function `ZNK7QStringgtERKS_':
c:/Qt/4.8.5/include/QtCore/../../src/corelib/tools/qstring.h:405: undefined reference to `_imp___ZNK7QStringltERKS_'
C:/Users/Sprint/Desktop/swe/marssies/libqxmpp_d.a(QXmppDiscoveryIq.o):c:/Qt/4.8.5/include/QtCore/../../src/corelib/tools/qalgorithms.h:161: more undefined references to `_imp___ZNK7QStringltERKS_' follow
C:/Users/Sprint/Desktop/swe/marssies/libqxmpp_d.a(QXmppIq.o): In function `ZNK7QXmppIq10getTypeStrEv':
C:\Users\Sprint\Desktop\swe\marssies\qxmpp-0.3.1\build-src-Qt_4_8_5-Debug/../src/QXmppIq.cpp:112: undefined reference to `_imp___Z8qWarningPKcz'
C:/Users/Sprint/Desktop/swe/marssies/libqxmpp_d.a(QXmppIq.o): In function `ZN7QXmppIq14setTypeFromStrERK7QString':
C:\Users\Sprint\Desktop\swe\marssies\qxmpp-0.3.1\build-src-Qt_4_8_5-Debug/../src/QXmppIq.cpp:143: undefined reference to `_imp___Z8qWarningPKcz'
C:/Users/Sprint/Desktop/swe/marssies/libqxmpp_d.a(moc_QXmppClient.o):moc_QXmppClient.cpp:(.rdata$_ZTV11QXmppClient[__ZTV11QXmppClient]+0x30): undefined reference to `QObject::connectNotify(char const*)'
C:/Users/Sprint/Desktop/swe/marssies/libqxmpp_d.a(moc_QXmppClient.o):moc_QXmppClient.cpp:(.rdata$_ZTV11QXmppClient[__ZTV11QXmppClient]+0x34): undefined reference to `QObject::disconnectNotify(char const*)'
C:/Users/Sprint/Desktop/swe/marssies/libqxmpp_d.a(moc_QXmppClientExtension.o):moc_QXmppClientExtension.cpp:(.rdata$_ZTV20QXmppClientExtension[__ZTV20QXmppClientExtension]+0x30): undefined reference to `QObject::connectNotify(char const*)'
C:/Users/Sprint/Desktop/swe/marssies/libqxmpp_d.a(moc_QXmppClientExtension.o):moc_QXmppClientExtension.cpp:(.rdata$_ZTV20QXmppClientExtension[__ZTV20QXmppClientExtension]+0x34): undefined reference to `QObject::disconnectNotify(char const*)'
C:/Users/Sprint/Desktop/swe/marssies/libqxmpp_d.a(moc_QXmppRosterManager.o):moc_QXmppRosterManager.cpp:(.rdata$_ZTV18QXmppRosterManager[__ZTV18QXmppRosterManager]+0x30): undefined reference to `QObject::connectNotify(char const*)'
C:/Users/Sprint/Desktop/swe/marssies/libqxmpp_d.a(moc_QXmppRosterManager.o):moc_QXmppRosterManager.cpp:(.rdata$_ZTV18QXmppRosterManager[__ZTV18QXmppRosterManager]+0x34): undefined reference to `QObject::disconnectNotify(char const*)'
C:/Users/Sprint/Desktop/swe/marssies/libqxmpp_d.a(QXmppRosterIq.o): In function `ZNK13QXmppRosterIq4Item22getSubscriptionTypeStrEv':
C:\Users\Sprint\Desktop\swe\marssies\qxmpp-0.3.1\build-src-Qt_4_8_5-Debug/../src/QXmppRosterIq.cpp:199: undefined reference to `_imp___Z8qWarningPKcz'
C:/Users/Sprint/Desktop/swe/marssies/libqxmpp_d.a(QXmppRosterIq.o): In function `ZN13QXmppRosterIq4Item26setSubscriptionTypeFromStrERK7QString':
C:\Users\Sprint\Desktop\swe\marssies\qxmpp-0.3.1\build-src-Qt_4_8_5-Debug/../src/QXmppRosterIq.cpp:220: undefined reference to `_imp___Z8qWarningPKcz'
C:/Users/Sprint/Desktop/swe/marssies/libqxmpp_d.a(QXmppRosterIq.o): In function `ZN9QHashNodeI7QString15QHashDummyValueE8same_keyEjRKS0_':
c:/Qt/4.8.5/include/QtCore/../../src/corelib/tools/qhash.h:225: undefined reference to `_imp___ZNK7QStringeqERKS_'
C:/Users/Sprint/Desktop/swe/marssies/libqxmpp_d.a(QXmppUtils.o): In function `Z18datetimeFromStringRK7QString':
C:\Users\Sprint\Desktop\swe\marssies\qxmpp-0.3.1\build-src-Qt_4_8_5-Debug/../src/QXmppUtils.cpp:122: undefined reference to `_imp___ZN5QCharC1Ec'
C:\Users\Sprint\Desktop\swe\marssies\qxmpp-0.3.1\build-src-Qt_4_8_5-Debug/../src/QXmppUtils.cpp:133: undefined reference to `_imp___ZNK9QDateTime7addSecsEi'
C:\Users\Sprint\Desktop\swe\marssies\qxmpp-0.3.1\build-src-Qt_4_8_5-Debug/../src/QXmppUtils.cpp:135: undefined reference to `_imp___ZNK9QDateTime7addSecsEi'
C:/Users/Sprint/Desktop/swe/marssies/libqxmpp_d.a(QXmppUtils.o): In function `Z13jidToResourceRK7QString':
C:\Users\Sprint\Desktop\swe\marssies\qxmpp-0.3.1\build-src-Qt_4_8_5-Debug/../src/QXmppUtils.cpp:193: undefined reference to `_imp___ZN5QCharC1Ec'
C:/Users/Sprint/Desktop/swe/marssies/libqxmpp_d.a(QXmppUtils.o): In function `Z9jidToUserRK7QString':
C:\Users\Sprint\Desktop\swe\marssies\qxmpp-0.3.1\build-src-Qt_4_8_5-Debug/../src/QXmppUtils.cpp:201: undefined reference to `_imp___ZN5QCharC1Ec'
C:/Users/Sprint/Desktop/swe/marssies/libqxmpp_d.a(QXmppUtils.o): In function `Z12jidToBareJidRK7QString':
C:\Users\Sprint\Desktop\swe\marssies\qxmpp-0.3.1\build-src-Qt_4_8_5-Debug/../src/QXmppUtils.cpp:209: undefined reference to `_imp___ZN5QCharC1Ec'
C:/Users/Sprint/Desktop/swe/marssies/libqxmpp_d.a(QXmppUtils.o): In function `ZN7QStringpLE5QChar':
c:/Qt/4.8.5/include/QtCore/../../src/corelib/tools/qstring.h:267: undefined reference to `_imp___ZN7QString4growEi'
c:/Qt/4.8.5/include/QtCore/../../src/corelib/tools/qstring.h:267: undefined reference to `_imp___ZN7QString7reallocEi'
C:/Users/Sprint/Desktop/swe/marssies/libqxmpp_d.a(moc_QXmppLogger.o):moc_QXmppLogger.cpp:(.rdata$_ZTV13QXmppLoggable[__ZTV13QXmppLoggable]+0x30): undefined reference to `QObject::connectNotify(char const*)'
C:/Users/Sprint/Desktop/swe/marssies/libqxmpp_d.a(moc_QXmppLogger.o):moc_QXmppLogger.cpp:(.rdata$_ZTV13QXmppLoggable[__ZTV13QXmppLoggable]+0x34): undefined reference to `QObject::disconnectNotify(char const*)'
C:/Users/Sprint/Desktop/swe/marssies/libqxmpp_d.a(moc_QXmppLogger.o):moc_QXmppLogger.cpp:(.rdata$_ZTV11QXmppLogger[__ZTV11QXmppLogger]+0x30): undefined reference to `QObject::connectNotify(char const*)'
C:/Users/Sprint/Desktop/swe/marssies/libqxmpp_d.a(moc_QXmppLogger.o):moc_QXmppLogger.cpp:(.rdata$_ZTV11QXmppLogger[__ZTV11QXmppLogger]+0x34): undefined reference to `QObject::disconnectNotify(char const*)'
C:/Users/Sprint/Desktop/swe/marssies/libqxmpp_d.a(moc_QXmppEntityTimeManager.o):moc_QXmppEntityTimeManager.cpp:(.rdata$_ZTV22QXmppEntityTimeManager[__ZTV22QXmppEntityTimeManager]+0x30): undefined reference to `QObject::connectNotify(char const*)'
C:/Users/Sprint/Desktop/swe/marssies/libqxmpp_d.a(moc_QXmppEntityTimeManager.o):moc_QXmppEntityTimeManager.cpp:(.rdata$_ZTV22QXmppEntityTimeManager[__ZTV22QXmppEntityTimeManager]+0x34): undefined reference to `QObject::disconnectNotify(char const*)'
C:/Users/Sprint/Desktop/swe/marssies/libqxmpp_d.a(moc_QXmppDiscoveryManager.o):moc_QXmppDiscoveryManager.cpp:(.rdata$_ZTV21QXmppDiscoveryManager[__ZTV21QXmppDiscoveryManager]+0x30): undefined reference to `QObject::connectNotify(char const*)'
C:/Users/Sprint/Desktop/swe/marssies/libqxmpp_d.a(moc_QXmppDiscoveryManager.o):moc_QXmppDiscoveryManager.cpp:(.rdata$_ZTV21QXmppDiscoveryManager[__ZTV21QXmppDiscoveryManager]+0x34): undefined reference to `QObject::disconnectNotify(char const*)'
C:/Users/Sprint/Desktop/swe/marssies/libqxmpp_d.a(QXmppDiscoveryManager.o): In function `ZN5QListIN16QXmppDiscoveryIq8IdentityEEpLERKS2_':
c:/Qt/4.8.5/include/QtCore/../../src/corelib/tools/qlist.h:826: undefined reference to `_imp___ZN9QListData7append2ERKS_'
C:/Users/Sprint/Desktop/swe/marssies/libqxmpp_d.a(QXmppOutgoingClient.o): In function `ZN19QXmppOutgoingClient13connectToHostEv':
C:\Users\Sprint\Desktop\swe\marssies\qxmpp-0.3.1\build-src-Qt_4_8_5-Debug/../src/QXmppOutgoingClient.cpp:158: undefined reference to `_imp___ZN15QAbstractSocket13connectToHostERK7QStringt6QFlagsIN9QIODevice12OpenModeFlagEE'
C:\Users\Sprint\Desktop\swe\marssies\qxmpp-0.3.1\build-src-Qt_4_8_5-Debug/../src/QXmppOutgoingClient.cpp:164: undefined reference to `_imp___ZNK7QString3argERKS_iRK5QChar'
C:/Users/Sprint/Desktop/swe/marssies/libqxmpp_d.a(QXmppOutgoingClient.o): In function `ZN19QXmppOutgoingClient13connectToHostERK12QXmppSrvInfo':
C:\Users\Sprint\Desktop\swe\marssies\qxmpp-0.3.1\build-src-Qt_4_8_5-Debug/../src/QXmppOutgoingClient.cpp:190: undefined reference to `_imp___ZN15QAbstractSocket13connectToHostERK7QStringt6QFlagsIN9QIODevice12OpenModeFlagEE'
C:/Users/Sprint/Desktop/swe/marssies/libqxmpp_d.a(QXmppOutgoingClient.o): In function `ZN19QXmppOutgoingClient11handleStartEv':
C:\Users\Sprint\Desktop\swe\marssies\qxmpp-0.3.1\build-src-Qt_4_8_5-Debug/../src/QXmppOutgoingClient.cpp:225: undefined reference to `_imp___ZN10QByteArrayC1EPKc'
C:/Users/Sprint/Desktop/swe/marssies/libqxmpp_d.a(QXmppOutgoingClient.o): In function `ZN19QXmppOutgoingClient12handleStanzaERK11QDomElement':

还有更多。

最后编辑

我为Qxmpp库做了同样的事情并解决了所有那些讨厌的错误。我现在还有其他错误,但我可以说这个问题已经回答了,因为我已经超越了这一点。非常感谢你。

1 个答案:

答案 0 :(得分:1)

我看到您使用的是第三方库QtSerialPortQextSerialPort。幸运的是,这些天我一直在和这两个可爱的家伙挣扎。

错误QString::fromUtf8&#34;可能&#34;来自QStringLiteral

中定义的宏qserialportglobal.h
#ifndef QStringLiteral
#define QStringLiteral(str) QString::fromUtf8(str)
#endif

<强> P.S。我使用的是Qt 4.8.5,可能会有一些不同。

gpssettingswidget.cpp 中,您不必再次添加qserialportglobal.h,因为它已包含在QSerialPort中。

删除包含并查看它是否变得更好,我知道处理这些多重错误是一项艰巨的工作,而这个答案肯定不是最终的补救措施。

至少看看有什么变化,我们可以在这里讨论。


<强> [编辑] 我看到您也在使用Qwt,我在使用QwtQtSerialPort时遇到了问题。 The question is here并且尚未解决。我通过迁移到QextSerialPort来绕过冲突。我怀疑可能存在一些图书馆冲突。

似乎只有 Laszlo Papp 可以保存你的屁股(他是QtSerialPort的作者之一)