Question

I am migrating a huge project from Qt 4.x to 5, I am almost finished but Im having errors that I cannot locate, I think it has to do with the linkage of some libraries but I am somewhat lost here. I hope someone can throw some light on this matter.

Errors:

  ./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]'

Project file:

# ----------------------------------------------------
# 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

Includes of addeditaton.cpp (if the rest of the code is needed please tell, they are 930 lines and I dont think they are relevant to the issue(

#include "addeditaton.h"
#include "atonwidget.h"
#include "atoninfowidget.h"
#include "messagebox.h"

#include <QtDebug>
#include <QFileDialog>
Was it helpful?

Solution

./release\addeditaton.o:addeditaton.cpp:(.text+0x6ac2): undefined reference to `_imp___ZN10HTTPClient5abortEv'

Lines like that usually means at least either of the following issues:

  • You do not have the corresponding library installed.

  • You do not have the correct version installed with the symbols you rely on.

  • Your linkage options are not set up properly.

In this case, the complain is about the http client library, so let us check your project file first. You are using the -L and -l options correctly in the beginning, but not in the end, so let us clarify what they mean:

-L means the path to the library.

-l either means the library name or absolute path to the library.

Now, let us see what you write at the end where the issue is:

-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" \

Therefore, you should replace this with the following:

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

Alternatively, you could also specify the absolute path to the static libraries with the -l option as mentioned above.

Note that you should not mix up things like QtSerialPort and QextSerialPort in your project, however. It is better to use QtSerialPort.

OTHER TIPS

You are using the -L option for the following libraries:

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

-L specifies a directory to search for libraries. Use the -l (lowercase) to specify a library. You may want to add a colon before the libarary name if you wnat to specify the exact name. For example,

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

See https://sourceware.org/binutils/docs/ld/Options.html#Options for details.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top