gpt4 book ai didi

C++ QtSoap 不工作: "undefined reference to ` QtSoapHttpTransport::QtSoapHttpTransport(QObject*)`

转载 作者:太空宇宙 更新时间:2023-11-04 11:42:44 26 4
gpt4 key购买 nike

我正在尝试让 QtSoap 正常工作。我正在使用这个库:https://qt.gitorious.org/qt-solutions/yjyong1217s-qt-solutions/source/4d83ff38ad836e507730034293d092df40b6d034:qtsoap

这是我的代码

#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();
}

这是头文件:

#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

无论我在做什么,它总是抛出这些编译错误:

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()'

我做错了什么?

编辑:

我尝试让 QtSOAP 在 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());
}
}

这是头文件:

#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

我得到这个错误输出:

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

最佳答案

假设您在 Qt 软件中使用基于 qmake 的构建系统,您需要执行以下操作:

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

在你的项目文件中。如果您查看示例,这是必要的。他们都在这样做。他们将其作为假库进行操作,因为在 ./config && qmake-qt4 -r && make VERBOSE=1 过程之后没有生成实际的库。

如果您使用的是不同的构建系统,则需要复制内部逻辑,但这对新手来说非常棘手,主要是因为它在内部使用了一些魔法,例如假目标,未记录的稀有性,例如 TEMPLATE += fakelib, 等

只是为了避免混淆:此模块尚未移植到 Qt 5,因此如果不包含一些工作,您无法立即使用它。您需要暂时坚持使用 Qt 4。

关于C++ QtSoap 不工作: "undefined reference to ` QtSoapHttpTransport::QtSoapHttpTransport(QObject*)`,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20789218/

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