salim_aliya
salim_aliya

Reputation: 273

C++ QtSoap doesn't work: "undefined reference to `QtSoapHttpTransport::QtSoapHttpTransport(QObject*)`

i am trying to get QtSoap working. I am using this library: https://qt.gitorious.org/qt-solutions/yjyong1217s-qt-solutions/source/4d83ff38ad836e507730034293d092df40b6d034:qtsoap

This is my Code

#include "sevSOAP.h"

sevSOAP::sevSOAP(int number1, int number2, QObject *parent) : QObject(parent), http(this)
{
    this->number1 = number1;
    this->number2 = number2;

    http.setHost(host);
    // Or use just http.setHost(host)
    connect(&http, SIGNAL(responseReady()), this, SLOT(getResponse()));

}

void sevSOAP::sum()
{
    QtSoapMessage request;

    request.setMethod("sum");
    request.addMethodArgument("number1", "", number1);
    request.addMethodArgument("number2", "", number2);

    http.submitRequest(request, "/soma");
}

void sevSOAP::getResponse()
{
    const QtSoapMessage &message = http.getResponse();
    if (message.isFault()) {
        qDebug("Error: %s", qPrintable(message.faultString().toString()));
    }
    qDebug()<< message.returnValue().toString();
}

And this is the header file:

#ifndef SEVSOAP_H
#define SEVSOAP_H

#include <qtsoap.h>

class sevSOAP : public QObject
{
    Q_OBJECT

    public:
        int number1;
        int number2;

        sevSOAP(int number1, int number2, QObject *parent = 0);
        void sum();

    private slots:
        void getResponse();

    private:
        QtSoapHttpTransport http;
};

#endif

No matter what i am doing, it always throws out these compiling errors:

C:\Projects/sevSOAP.cpp:3: undefined reference to `QtSoapHttpTransport::QtSoapHttpTransport(QObject*)'
C:\Projects/sevSOAP.cpp:8: undefined reference to `QtSoapHttpTransport::setHost(QString const&, bool, int)'
C:\Projects/sevSOAP.cpp:12: undefined reference to `QtSoapHttpTransport::~QtSoapHttpTransport()'
C:\Projects/sevSOAP.cpp:3: undefined reference to `QtSoapHttpTransport::QtSoapHttpTransport(QObject*)'
C:\Projects/sevSOAP.cpp:8: undefined reference to `QtSoapHttpTransport::setHost(QString const&, bool, int)'
C:\Projects/sevSOAP.cpp:12: undefined reference to `QtSoapHttpTransport::~QtSoapHttpTransport()'

What have i been doing wrong?

EDIT:

I have tried to make QtSOAP run under QtCreator:

#include <QApplication>
#include "sevSOAP.h"

sevSOAP::sevSOAP(QObject *parent) : QObject(parent), http(this)
{
    connect(&http, SIGNAL(responseReady()), this, SLOT(getResponse()));

    QtSoapMessage request;

    request.setMethod("TCKimlikNoDogrula");

    request.addMethodArgument("TCKimlikNo", "", "10000000146");
    request.addMethodArgument("Ad", "", "mustafa");
    request.addMethodArgument("Soyad", "", "atatürk");
    request.addMethodArgument("DogumYili", "", "1881");

    http.setHost("tckimlik.nvi.gov.tr", true);
    http.setAction("http://tckimlik.nvi.gov.tr/WS/TCKimlikNoDogrula");
    http.submitRequest(request, "/Service/KPSPublic.asmx?op=TCKimlikNoDogrula");

    qDebug("Looking up population of...");
}

void sevSOAP::getResponse()
{
    // Get a reference to the response message.
    const QtSoapMessage &message = http.getResponse();

    // Check if the response is a SOAP Fault message
    if (message.isFault()) {
        qDebug("Error: %s", message.faultString().value().toString().toLatin1().constData());
    }
    else {
        // Get the return value, and print the result.
        const QtSoapType &response = message.returnValue();
        qDebug("%s has a population of %s (last updated at %s)",
               response["Country"].value().toString().toLatin1().constData(),
               response["Pop"].value().toString().toLatin1().constData(),
               response["Date"].value().toString().toLatin1().constData());
    }
}

this is the header file:

#ifndef SEVSOAP_H
#define SEVSOAP_H

#include <qtsoap.h>

class sevSOAP : public QObject
{
    Q_OBJECT

    public:
        sevSOAP(QObject *parent = 0);

    private slots:
        void getResponse();

    private:
        QtSoapHttpTransport http;
};

#endif

and i am getting this error output:

mingw32-make[1]: Entering directory 'C:/Users/<user>/Projects/Release'
g++ -Wl,-s -Wl,-subsystem,windows -mthreads -o release/TCKimlikNoSorgulama.exe release/qtsoap.o release/main.o release/newForm.o release/sevSOAP.o release/moc_qtsoap.o release/moc_newForm.o release/moc_sevSOAP.o  -lglu32 -lopengl32 -lgdi32 -luser32 -lmingw32 -lqtmain -LC:\Developement\Qt\5.2.0\mingw48_32\lib -lQt5Widgets -lQt5Network -lQt5Xml -lQt5Gui -lQt5Core 
release/qtsoap.o:qtsoap.cpp:(.text+0x458): undefined reference to `_imp___ZTV10QtSoapType'
release/qtsoap.o:qtsoap.cpp:(.text+0x6b8): undefined reference to `_imp___ZTV16QtSoapSimpleType'
release/qtsoap.o:qtsoap.cpp:(.text+0x718): undefined reference to `_imp___ZTV11QtSoapArray'
release/qtsoap.o:qtsoap.cpp:(.text+0x10aa): undefined reference to `_imp___ZTV10QtSoapType'
release/qtsoap.o:qtsoap.cpp:(.text+0x162a): undefined reference to `_imp___ZTV10QtSoapType'
release/qtsoap.o:qtsoap.cpp:(.text+0x1732): undefined reference to `_imp___ZTV10QtSoapType'
release/qtsoap.o:qtsoap.cpp:(.text+0x2e5a): undefined reference to `_imp___ZTV11QtSoapArray'
release/qtsoap.o:qtsoap.cpp:(.text+0x2f4b): undefined reference to `_imp___ZTV11QtSoapArray'
release/qtsoap.o:qtsoap.cpp:(.text+0x3656): undefined reference to `_imp___ZTV12QtSoapStruct'
release/qtsoap.o:qtsoap.cpp:(.text+0x36eb): undefined reference to `_imp___ZTV12QtSoapStruct'
release/qtsoap.o:qtsoap.cpp:(.text+0x384c): undefined reference to `_imp___ZTV16QtSoapSimpleType'
release/qtsoap.o:qtsoap.cpp:(.text+0x388b): undefined reference to `_imp___ZTV16QtSoapSimpleType'
release/qtsoap.o:qtsoap.cpp:(.text+0x38dc): undefined reference to `_imp___ZTV16QtSoapSimpleType'
release/qtsoap.o:qtsoap.cpp:(.text+0x3940): undefined reference to `_imp___ZTV16QtSoapSimpleType'
release/qtsoap.o:qtsoap.cpp:(.text+0x399c): undefined reference to `_imp___ZTV16QtSoapSimpleType'
release/qtsoap.o:qtsoap.cpp:(.text+0x39f7): more undefined references to `_imp___ZTV16QtSoapSimpleType' follow
release/qtsoap.o:qtsoap.cpp:(.text+0x43e8): undefined reference to `_imp___ZTV12QtSoapStruct'
release/qtsoap.o:qtsoap.cpp:(.text+0x4694): undefined reference to `_imp___ZTV11QtSoapArray'
release/qtsoap.o:qtsoap.cpp:(.text+0x6d34): undefined reference to `_imp___ZTV12QtSoapStruct'
release/qtsoap.o:qtsoap.cpp:(.text+0x7137): undefined reference to `_imp___ZTV12QtSoapStruct'
release/qtsoap.o:qtsoap.cpp:(.text+0x736f): undefined reference to `_imp___ZTV12QtSoapStruct'
release/qtsoap.o:qtsoap.cpp:(.text+0x7c5f): undefined reference to `_imp___ZTV12QtSoapStruct'
release/qtsoap.o:qtsoap.cpp:(.text+0x7e7b): undefined reference to `_imp___ZTV12QtSoapStruct'
release/qtsoap.o:qtsoap.cpp:(.text+0x8394): more undefined references to `_imp___ZTV12QtSoapStruct' follow
release/qtsoap.o:qtsoap.cpp:(.text+0xa38a): undefined reference to `_imp___ZTV21QtSoapTypeConstructorI12QtSoapStructE'
release/qtsoap.o:qtsoap.cpp:(.text+0xa3cd): undefined reference to `_imp___ZTV21QtSoapTypeConstructorI11QtSoapArrayE'
release/qtsoap.o:qtsoap.cpp:(.text+0xa408): undefined reference to `_imp___ZTV21QtSoapTypeConstructorI16QtSoapSimpleTypeE'
release/qtsoap.o:qtsoap.cpp:(.text+0xc430): undefined reference to `_imp___ZN19QtSoapHttpTransport13responseReadyEv'
release/qtsoap.o:qtsoap.cpp:(.text+0xc43b): undefined reference to `_imp___ZN19QtSoapHttpTransport13responseReadyERK13QtSoapMessage'
release/qtsoap.o:qtsoap.cpp:(.text+0xe4aa): undefined reference to `_imp___ZTV12QtSoapStruct'
release/qtsoap.o:qtsoap.cpp:(.text+0xe7aa): undefined reference to `_imp___ZTV19QtSoapHttpTransport'
release/qtsoap.o:qtsoap.cpp:(.text+0xe888): undefined reference to `_imp___ZTV19QtSoapHttpTransport'
release/qtsoap.o:qtsoap.cpp:(.text$_ZN25QtSoapTypeConstructorBaseD1Ev[__ZN25QtSoapTypeConstructorBaseD1Ev]+0xffff1681): undefined reference to `_imp___ZTV25QtSoapTypeConstructorBase'
Makefile.Release:88: recipe for target 'release/TCKimlikNoSorgulama.exe' failed
c:/developement/qt/tools/mingw48_32/bin/../lib/gcc/i686-w64-mingw32/4.8.0/../../../../i686-w64-mingw32/bin/ld.exe: release/qtsoap.o: bad reloc address 0x1 in section `.text$_ZN25QtSoapTypeConstructorBaseD1Ev[__ZN25QtSoapTypeConstructorBaseD1Ev]'
collect2.exe: error: ld returned 1 exit status

Upvotes: 1

Views: 977

Answers (1)

L&#225;szl&#243; Papp
L&#225;szl&#243; Papp

Reputation: 53215

Assuming you are using a qmake based build system in your Qt software, you need to do the following:

include(C:/path/to/qtsoap.pri)

in your project file. This is necessary if you take a look at the examples. All of them are doing this. They are manipulating with it as a fake library as there is no actual library generated after the ./config && qmake-qt4 -r && make VERBOSE=1 process.

If you are using a different buildsystem, you will need to replicate the logic inside, but it is quite tricky for a newcomer, mostly because it is using some magic inside like phony target, undocumented rarity like TEMPLATE += fakelib, et al.

Just to avoid the confusion: this module has not yet been ported over to Qt 5, hence you cannot get it working off-hand without some work included. You need to stick to Qt 4 with it for the time being.

Upvotes: 1

Related Questions