I have now reduced this crash to a single line in the project file:
QT -= gui
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:
#include <QCoreApplication>
#include "../qt-solutions/qtservice/src/qtservice.h"
class Service : public QtService<QCoreApplication>
{
public:
Service(int argc, char** argv, const QString& name)
: QtService<QCoreApplication>(argc, argv, name)
{
}
protected:
void start()
{
logMessage("Start");
}
void stop()
{
logMessage("Stop");
}
};
int main(int argc, char** argv)
{
Service service(argc, argv, "Test service");
return service.exec();
}
#include <QCoreApplication>
#include "../qt-solutions/qtservice/src/qtservice.h"
class Service : public QtService<QCoreApplication>
{
public:
Service(int argc, char** argv, const QString& name)
: QtService<QCoreApplication>(argc, argv, name)
{
}
protected:
void start()
{
logMessage("Start");
}
void stop()
{
logMessage("Stop");
}
};
int main(int argc, char** argv)
{
Service service(argc, argv, "Test service");
return service.exec();
}
To copy to clipboard, switch view to plain text mode
Project:
SOURCES += main.cpp
# This line triggers crash:
QT -= gui
include(../qt-solutions/qtservice/src/qtservice.pri)
SOURCES += main.cpp
# This line triggers crash:
QT -= gui
include(../qt-solutions/qtservice/src/qtservice.pri)
To copy to clipboard, switch view to plain text mode
Init script:
#! /bin/sh
### BEGIN INIT INFO
# Provides: testservice
# Required-Start: $network $local_fs $syslog dbus
# Required-Stop: $network $local_fs $syslog dbus
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: testservice
# Description: testservice
### END INIT INFO
EXE=/path/to/service
test -x $EXE || exit 0
USER=serviceuser
GROUP=serviceuser
. /lib/lsb/init-functions
case "$1" in
start)
log_daemon_msg "Starting test service" "testservice"
if start-stop-daemon --start --quiet --oknodo --chuid ${USER}:${GROUP} --exec $EXE; then
log_end_msg 0
else
log_end_msg 1
fi
;;
stop)
log_daemon_msg "Shutting down test service" "testservice"
if start-stop-daemon --stop --quiet --oknodo --exec $EXE; then
log_end_msg 0
else
log_end_msg 1
fi
;;
restart)
$0 stop
$0 start
;;
*)
log_action_msg "Usage: $0 {start|stop|restart}"
exit 1
;;
esac
exit 0
#! /bin/sh
### BEGIN INIT INFO
# Provides: testservice
# Required-Start: $network $local_fs $syslog dbus
# Required-Stop: $network $local_fs $syslog dbus
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: testservice
# Description: testservice
### END INIT INFO
EXE=/path/to/service
test -x $EXE || exit 0
USER=serviceuser
GROUP=serviceuser
. /lib/lsb/init-functions
case "$1" in
start)
log_daemon_msg "Starting test service" "testservice"
if start-stop-daemon --start --quiet --oknodo --chuid ${USER}:${GROUP} --exec $EXE; then
log_end_msg 0
else
log_end_msg 1
fi
;;
stop)
log_daemon_msg "Shutting down test service" "testservice"
if start-stop-daemon --stop --quiet --oknodo --exec $EXE; then
log_end_msg 0
else
log_end_msg 1
fi
;;
restart)
$0 stop
$0 start
;;
*)
log_action_msg "Usage: $0 {start|stop|restart}"
exit 1
;;
esac
exit 0
To copy to clipboard, switch view to plain text mode
Bookmarks