Posted on 25-10-2013
Filed Under (Technology) by bigbang

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


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:




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'
NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio 9.0\VC\bin
\nmake.exe"' : return code '0x2'
NMAKE : fatal error U1077: 'cd' : return code '0x2'

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

© 2013, The Big Bang on Reading Busy. All rights reserved.
On republishing this post you must provide link to the original post.

Post a Comment