0

As part of my Qt project, I have a WSO2 WSF/C++ module as a webservice. Now the instructions to build this module are pretty straight-forward in CLI (Windows environment):

To compile:

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

To link:

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


In order to automate the build process, I want to integrate these steps to my .pro file. However I have absolutely no idea how to proceed. Any suggestions?


EDIT: Here's my current code:

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

hello.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

hello.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;
}
elyas-bhy
  • 772
  • 1
  • 14
  • 23
  • possible duplicate of [Running a program/script from QMake](http://stackoverflow.com/questions/3612283/running-a-program-script-from-qmake) – hyde Nov 08 '13 at 18:38

1 Answers1

1

Create a .pro file like this:

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

and integrate it into your build process. That will require the Qt/qmake you're using to be compiled for MSVC. (but mixing mingw and MSVC inside a single project wouldn't work anyway)

Frank Osterfeld
  • 24,815
  • 5
  • 58
  • 70
  • This is exactly want I was looking for, thank you! So I have added this code snippet to my .pro file, but the compilation fails during the linking phase (several LNK2019 unresolved external symbol errors). I have two questions: 1. How do I specify linking directives within the .pro file? 2. What does the following line mean: TEMPLATE = lib – elyas-bhy Nov 08 '13 at 20:10
  • 1
    I edited the answer to link the libs (don't know if this is exactly what's needed). `TEMPLATE = lib` tells qmake to create a DLL. (Opposed to `app`, which creates an .exe) – Frank Osterfeld Nov 08 '13 at 20:40
  • We're almost there... The previous errors are fixed, but now I am getting an LNK1104: cannot open file 'axutil.lib' – elyas-bhy Nov 08 '13 at 20:47
  • 1
    You might have to add the path to the libs via `-L`, e.g. `-L$$WSFCPP_HOME/lib`. – Frank Osterfeld Nov 08 '13 at 20:53
  • Adding `-L$$WSFCPP_HOME/lib` didn't seem to change anything. However I tried `-L$${WSFCPP_HOME/lib}`, and now I got an LNK1146 no argument specified with option '/LIBPATH' error. I looked at the generated makefile: `LIBS = /LIBPATH: axutil.lib axiom.lib axis2_parser.lib axis2_engine.lib wso2_wsf.lib` Somehow the WSFCPP_HOME variable did not get expanded... any ideas? – elyas-bhy Nov 08 '13 at 22:13
  • 1
    Well, did you set the WSFCPP_HOME environment variable? Or try with a hardcoded path first. – Frank Osterfeld Nov 09 '13 at 08:29
  • The WSFCPP_HOME variable is correctly set. When I use a hardcoded path, I get several LNK2019 errors again, like in my first comment (although the generated makefile looks correct now). – elyas-bhy Nov 09 '13 at 11:07
  • I found out that Qt 64bits and WSO2 32bits didn't get along very well. I tried Qt 32bits and now it's building properly. Marking this as resolved, thanks for the help! – elyas-bhy Nov 20 '13 at 16:52