gpt4 book ai didi

c++ - 配置 Qt .pro 文件以使用 cl.exe 和 link.exe 修复链接错误

转载 作者:行者123 更新时间:2023-11-28 07:18:40 24 4
gpt4 key购买 nike

作为我的 Qt 项目的一部分,我有一个 WSO2 WSF/C++ 模块作为网络服务。现在,构建此模块的说明在 CLI(Windows 环境)中非常简单:

编译:

cl.exe/D "WIN32"/D "_WINDOWS"/D "_MBCS"/D "AXIS2_DECLARE_EXPORT"/D "AXIS2_SVR_MULTI_THREADED"/w/nologo/I %WSFCPP_HOME%\include/c hello.cpp

链接:

link.exe/nologo/LIBPATH:%WSFCPP_HOME%\lib axutil.lib axiom.lib axis2_parser.lib axis2_engine.lib wso2_wsf.lib/DLL/OUT:hello.dll *.obj


为了自动化构建过程,我想将这些步骤集成到我的 .pro 文件中。但是我完全不知道如何进行。有什么建议吗?


编辑:这是我当前的代码:

project.pro

TEMPLATE = lib
CONFIG += dll
CONFIG -= qt
VERSION = 1.0

TARGET = hello
SOURCES += hello.cpp
HEADERS += hello.hpp

DEFINES += AXIS2_DECLARE_EXPORT AXIS2_SVR_MULTI_THREADED

INCLUDEPATH += "C:\wsfcpp\include"

LIBS += \
-L"C:\wsfcpp\lib" -laxutil \
-laxiom \
-laxis2_parser \
-laxis2_engine \
-lwso2_wsf

你好.hpp

#ifndef HELLO_H
#define HELLO_H

#include <ServiceSkeleton.h>
using namespace wso2wsf;

class Hello : public ServiceSkeleton
{
public:
WSF_EXTERN WSF_CALL Hello(){};
OMElement* WSF_CALL invoke(OMElement *message, MessageContext *msgCtx);
OMElement* WSF_CALL onFault(OMElement *message);
void WSF_CALL init();
OMElement* greet(OMElement *inMsg);
};
#endif // HELLO_H

你好.cpp

#include <ServiceSkeleton.h>
#include <iostream>
#include <stdio.h>
#include <axutil_env.h>
#include <Environment.h>
#include <OMText.h>
#include "hello.hpp"

using namespace wso2wsf;
using namespace std;

/** Load the service into axis2 engine */
WSF_SERVICE_INIT(Hello)

OMElement* Hello::invoke(OMElement *ele, MessageContext *msgCtx)
{
return greet(ele);
}

OMElement* Hello::onFault(OMElement *ele)
{
OMElement *responseEle = new OMElement("HelloServiceErrorResponse");
responseEle->setText("Hello Service Failed");
return responseEle;
}

void Hello::init()
{

}

OMElement* Hello::greet(OMElement* inMsg)
{
OMElement *helloEle = new OMElement("greetResponse");
OMElement *text = new OMElement("text");
helloEle->setText(greet);
return helloEle;
}

最佳答案

像这样创建一个 .pro 文件:

TEMPLATE = lib
TARGET = hello

DEFINES += AXIS2_DECLARE_EXPORT AXIS2_SVR_MULTI_THREADED
SOURCES += hello.cpp
LIBS += -Lpath/to/the/libs -laxutil -laxiom -laxis2_parser -laxis2_engine -lwso2_wsf

并将其集成到您的构建过程中。这将需要为 MSVC 编译您正在使用的 Qt/qmake。 (但是在单个项目中混合使用 mingw 和 MSVC 无论如何都行不通)

关于c++ - 配置 Qt .pro 文件以使用 cl.exe 和 link.exe 修复链接错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19865943/

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