I have now reduced this crash to a single line in the project file:

Qt Code:
  1. QT -= gui
To copy to clipboard, switch view to plain text mode 

With this line, the crash occurs. Without this line, is does not... weird.

For some reason, qmake implicitly builds against QtGui, even though there is no obvious gui dependency in my code or qtservice. I really don't want my binary to depend on the gui libs, so i supress it using the line above...

Code:
Qt Code:
  1. #include <QCoreApplication>
  2.  
  3. #include "../qt-solutions/qtservice/src/qtservice.h"
  4.  
  5. class Service : public QtService<QCoreApplication>
  6. {
  7. public:
  8. Service(int argc, char** argv, const QString& name)
  9. : QtService<QCoreApplication>(argc, argv, name)
  10. {
  11. }
  12.  
  13. protected:
  14. void start()
  15. {
  16. logMessage("Start");
  17. }
  18.  
  19. void stop()
  20. {
  21. logMessage("Stop");
  22. }
  23. };
  24.  
  25. int main(int argc, char** argv)
  26. {
  27. Service service(argc, argv, "Test service");
  28. return service.exec();
  29. }
To copy to clipboard, switch view to plain text mode 

Project:
Qt Code:
  1. SOURCES += main.cpp
  2. # This line triggers crash:
  3. QT -= gui
  4. include(../qt-solutions/qtservice/src/qtservice.pri)
To copy to clipboard, switch view to plain text mode 

Init script:
Qt Code:
  1. #! /bin/sh
  2.  
  3. ### BEGIN INIT INFO
  4. # Provides: testservice
  5. # Required-Start: $network $local_fs $syslog dbus
  6. # Required-Stop: $network $local_fs $syslog dbus
  7. # Default-Start: 2 3 4 5
  8. # Default-Stop: 0 1 6
  9. # Short-Description: testservice
  10. # Description: testservice
  11. ### END INIT INFO
  12.  
  13. EXE=/path/to/service
  14. test -x $EXE || exit 0
  15.  
  16. USER=serviceuser
  17. GROUP=serviceuser
  18.  
  19. . /lib/lsb/init-functions
  20.  
  21. case "$1" in
  22. start)
  23. log_daemon_msg "Starting test service" "testservice"
  24. if start-stop-daemon --start --quiet --oknodo --chuid ${USER}:${GROUP} --exec $EXE; then
  25. log_end_msg 0
  26. else
  27. log_end_msg 1
  28. fi
  29. ;;
  30. stop)
  31. log_daemon_msg "Shutting down test service" "testservice"
  32. if start-stop-daemon --stop --quiet --oknodo --exec $EXE; then
  33. log_end_msg 0
  34. else
  35. log_end_msg 1
  36. fi
  37. ;;
  38. restart)
  39. $0 stop
  40. $0 start
  41. ;;
  42. *)
  43. log_action_msg "Usage: $0 {start|stop|restart}"
  44. exit 1
  45. ;;
  46. esac
  47.  
  48. exit 0
To copy to clipboard, switch view to plain text mode