Using QtService Library Under Windows
Contents
QtService is a library not maintained by Qt right now, but a lot of engineers find that it is useful when you want to write a Windows application with Windows Service.
First, git clone the code from
git://gitorious.org/qt-solutions/qt-solutions.git
After checkout, there is a folder qtservice which is the target in this post. Enter the folder and we will compile the library for later usage.
Second, compile the code into a library under Windows. Use Qt Command Prompt, jump to the source folder and use following commands to compile it:
configure.bat
qmake
nmake.exe
The nmake.exe is the Visual Studio compiler, you can find it under Visual Studio installation path.
If the command prompt provides you with an error code:
NMAKE : fatal error U1077: ‘cl’ : return code ‘0x1’ Stop. NMAKE : fatal error U1077: ‘“C:\Program Files\Microsoft Visual Studio 9.0\VC\bin \nmake.exe”’ : return code ‘0x2’ Stop. NMAKE : fatal error U1077: ‘cd’ : return code ‘0x2’ Stop.
The reason is that you don’t use Qt Command Prompt.
After Compiled the code successfully, you can copy qtservice.h and generated library files such as QtSolutions_Service-head.dll, QtSolutions_Service-head.lib to your project folder. You link them in your pro file, then you can write QtService code. Just read examples under doc folder, and you will find the way.
If you use QtService in your application which name is example.exe for example, you can use following command to check the usage:
example.exe -help
and you can use following command to run the application as normal command line tool:
example.exe -exec
Author Watterry
LastMod 2013-10-26