gpt4 book ai didi

c++ - 对 `_imp___ZN10HTTPClient5abortEv' 和其他的 undefined reference

转载 作者:行者123 更新时间:2023-11-30 00:50:56 25 4
gpt4 key购买 nike

我正在将一个巨大的项目从 Qt 4.x 迁移到 5,我快完成了,但我遇到了无法定位的错误,我认为这与某些库的链接有关,但我在这里有些迷路。我希望有人能对此事有所了解。

错误:

  ./release\addeditaton.o:addeditaton.cpp:(.text+0x6ac2): undefined reference to `_imp___ZN10HTTPClient5abortEv'
./release\addeditaton.o:addeditaton.cpp:(.text+0x98c5): undefined reference to `_imp___ZN10HTTPClient3getE7QStringbb'
./release\addeditaton.o:addeditaton.cpp:(.text+0x9f88): undefined reference to `_imp___ZN10HTTPClient3getE7QStringbb'
./release\addeditaton.o:addeditaton.cpp:(.text+0xa7a8): undefined reference to `_imp___ZN10HTTPClient3getE7QStringbb'
./release\addeditaton.o:addeditaton.cpp:(.text+0xa921): undefined reference to `_imp___ZN10RestClientC2E7QStringibS0_S0_S0_S0_'
./release\addeditaton.o:addeditaton.cpp:(.text+0xc91b): undefined reference to `_imp___ZN10HTTPClient3getE7QStringbb'
./release\addeditaton.o:addeditaton.cpp:(.text+0xcaa3): undefined reference to `_imp___ZN10RestClientC2E7QStringibS0_S0_S0_S0_'
./release\addeditaton.o:addeditaton.cpp:(.text+0xe49d): undefined reference to `_imp___ZN10HTTPClient4postE7QStringS0_b'
./release\addeditaton.o:addeditaton.cpp:(.text+0xfc55): undefined reference to `_imp___ZN10HTTPClient4postE7QStringS0_b'
Makefile.Release:922: recipe for target '..\Release\Swibz.exe' failed
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: ./release\addeditaton.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:addeditaton.cpp:(.text+0x6ac2): undefined reference to `_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 之类的东西。最好使用 QtSerialPort。

关于c++ - 对 `_imp___ZN10HTTPClient5abortEv' 和其他的 undefined reference ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23335157/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com