对"_imp___ZN10HTTPClient5abortEv"和其他内容的未定义引用



我正在将一个巨大的项目从Qt4.x迁移到5,我几乎完成了,但我遇到了无法定位的错误,我认为这与一些库的链接有关,但我在这里有些迷失了方向。我希望有人能澄清这件事。

错误:

  ./releaseaddeditaton.o:addeditaton.cpp:(.text+0x6ac2): undefined reference to `_imp___ZN10HTTPClient5abortEv'
    ./releaseaddeditaton.o:addeditaton.cpp:(.text+0x98c5): undefined reference to `_imp___ZN10HTTPClient3getE7QStringbb'
    ./releaseaddeditaton.o:addeditaton.cpp:(.text+0x9f88): undefined reference to `_imp___ZN10HTTPClient3getE7QStringbb'
    ./releaseaddeditaton.o:addeditaton.cpp:(.text+0xa7a8): undefined reference to `_imp___ZN10HTTPClient3getE7QStringbb'
    ./releaseaddeditaton.o:addeditaton.cpp:(.text+0xa921): undefined reference to `_imp___ZN10RestClientC2E7QStringibS0_S0_S0_S0_'
    ./releaseaddeditaton.o:addeditaton.cpp:(.text+0xc91b): undefined reference to `_imp___ZN10HTTPClient3getE7QStringbb'
    ./releaseaddeditaton.o:addeditaton.cpp:(.text+0xcaa3): undefined reference to `_imp___ZN10RestClientC2E7QStringibS0_S0_S0_S0_'
    ./releaseaddeditaton.o:addeditaton.cpp:(.text+0xe49d): undefined reference to `_imp___ZN10HTTPClient4postE7QStringS0_b'
    ./releaseaddeditaton.o:addeditaton.cpp:(.text+0xfc55): undefined reference to `_imp___ZN10HTTPClient4postE7QStringS0_b'
    Makefile.Release:922: recipe for target '..ReleaseSwibz.exe' failed
    c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: ./releaseaddeditaton.o: bad reloc address 0x20 in section `.text$_ZN10QByteArrayD1Ev[__ZN10QByteArrayD1Ev]'

项目文件:

# ----------------------------------------------------
# This file is generated by the Qt Visual Studio Add-in.
# ------------------------------------------------------
TEMPLATE = app
TARGET = Swibz
include(Swibz.pri)
DESTDIR = ../Release
QT += widgets network xml webkit webkitwidgets opengl #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/qwt-5.2.0/src 
    ../qwt/src 
    #../../../QENC/QENC 
    ../qenc 
   # ../../../zlib-1.2.5 
    ../zlib-1.2.5 
    #../../../serial/qextserialport-1.2win-alpha 
    ../qextserialport-1.2win-alpha 
   # ../../../qxmpp-0.3.0/src 
    ../qxmpp/build-qxmpp-Qt_4_8_5-Debug/src 
    #../../../JSON 
    ../json/JSON 
   # ../../../QtSerialPort/qtserialport/include
    ../QtSerialPort/qtserialport/include
LIBS += -L"../../../SprintLib/release" 
    -L"../../../QENC/release" 
    -L"../../../zlib-1.2.5/contrib/vstudio/vc9/x86/ZlibDllRelease" 
    -L"../../../serial/qextserialport-1.2win-alpha/Release" 
    -L"../../../qxmpp-0.3.0/lib" 
    -L"../../../JSON/Release" 
    -L"../../../QtSerialPort/qtserialport/src/serialport/release" 
    -lopengl32 
    -lglu32 
    -lgdi32 
    -luser32 
    #-lHDP 
    -L"./libHDP.a" 
    #-l../../Qwt/qwt-5.2.0/lib/debug/qwt5 
    #-lqenc 
    #-lzlibwapi 
    -L"./zlib1.dll" 
    #-lqextserialport 
    -lsetupapi 
    #-lqxmpp 
    -L"./libqxmpp.a" 
    #-ljson_lib 
    #-lSerialPort1
    -L"./libqextserialportd.a" 
#DEPENDPATH += .
#MOC_DIR += ./GeneratedFiles/release
#OBJECTS_DIR += release
#UI_DIR += ./GeneratedFiles
#eRCC_DIR += ./GeneratedFiles
#win32:RC_FILE = Swibz.rc
TRANSLATIONS = ln_en.ts
TRANSLATIONS = ln_lv.ts
TRANSLATIONS = ln_lt.ts
TRANSLATIONS = ln_es.ts
CODECFORTR     = UTF-8

包括addeditaton.cpp(如果需要其余代码,请告知,它们是930行,我认为它们与问题无关(

#include "addeditaton.h"
#include "atonwidget.h"
#include "atoninfowidget.h"
#include "messagebox.h"
#include <QtDebug>
#include <QFileDialog>

/release\addeditaton.o:addeditatoon.cpp:(.text+0x6ac2):对`_imp___ZN10HTTPClient5abortEv'的未定义引用

这样的行通常意味着至少以下任一问题:

  • 您没有安装相应的库。

  • 您没有安装正确的符号版本。

  • 您的链接选项设置不正确。

在这种情况下,抱怨是关于http客户端库的,所以让我们先检查您的项目文件。您在开始时正确使用了-L-l选项,但最终没有正确使用,因此让我们澄清它们的含义:

-L表示到库的路径。

-l表示库名称或库的绝对路径。

现在,让我们看看你在最后写了什么,问题是:

-L"./libHDP.a" 
#-l../../Qwt/qwt-5.2.0/lib/debug/qwt5 
#-lqenc 
#-lzlibwapi 
-L"./zlib1.dll" 
#-lqextserialport 
-lsetupapi 
#-lqxmpp 
-L"./libqxmpp.a" 
#-ljson_lib 
#-lSerialPort1
-L"./libqextserialportd.a" 

因此,您应该将其替换为以下内容:

-lHDP
#-l../../Qwt/qwt-5.2.0/lib/debug/qwt5 
#-lqenc 
#-lzlibwapi 
-lzlib1 
#-lqextserialport 
-lsetupapi 
#-lqxmpp 
-lqxmpp.a 
#-ljson_lib 
#-lSerialPort1 
-lqextserialportd

或者,您也可以使用-l选项指定静态库的绝对路径,如上所述。

请注意,您不应该在项目中混淆QtSerialPort和QextSerialPort之类的东西。最好使用QtSarialPort。

您正在为以下库使用-L选项:

-L"./libHDP.a" 
-L"./zlib1.dll" 
-L"./libqxmpp.a" 
-L"./libqextserialportd.a" 

-L指定要搜索库的目录。使用-l(小写)可以指定库。如果您想要指定确切的名称,您可能需要在库名称之前添加一个冒号。例如,

-l :./libHDP.a  
-l :./zlib1.dll 
-l :./libqxmpp.a 
-l :./libqextserialportd.a 

请参阅https://sourceware.org/binutils/docs/ld/Options.html#Options详细信息。

相关内容

  • 没有找到相关文章

最新更新