Linux daemon with wxWidgets

56 views
Skip to first unread message

Сергей Коныгин

unread,
Feb 20, 2024, 11:51:41 PMFeb 20
to wx-users
Hi!

I want to create a linux daemon that uses wxWidgets. But I couldn't find any examples. The example of the windows service uses IMPLEMENT_APP_NO_MAIN(MainApp) alongside the function WinMain.
Can I use IMPLEMENT_APP_NO_MAIN(MainApp) with function "main"?

Kenneth Porter

unread,
Feb 21, 2024, 12:24:18 AMFeb 21
to wx-u...@googlegroups.com
I just wrote a simple command line app that shows where to put custom
code. Look at the class wxCheckSizerFlagsApp here:

https://github.com/SpareSimian/wxCheckSizerFlags/blob/main/wxCheckSizerFlags.cpp


Simon Richter

unread,
Feb 21, 2024, 5:01:56 AMFeb 21
to wx-u...@googlegroups.com, Сергей Коныгин
Hi,
In principle, yes. Linux daemons need to do a lot less early setup
compared to a Windows service, so you might even get away with a normal
IMPLEMENT_APP_CONSOLE and using the provided "main" function.

The _CONSOLE is there because daemons normally don't have GUI access.
Normally the daemon would provide a network service, and accept
connections from GUI programs that control it.

If the service is meant to be used from the local desktop only, then
dbus is the appropriate connection mechanism.

Simon

Сергей Коныгин

unread,
Feb 21, 2024, 12:05:33 PMFeb 21
to wx-users
Thanks!
Now I have the compiled wxWidgets with GTK and so on. Do I need to rebuild wxWidgets without GUI for Linux daemon? If so how can I do it?

среда, 21 февраля 2024 г. в 14:01:56 UTC+4, Simon Richter:

Gunter Königsmann

unread,
Feb 21, 2024, 12:22:53 PMFeb 21
to wx-u...@googlegroups.com
In the examples directory of wxWidgets there should be a console example. Basically you derive your Application not from wxApp, but from wxAppConsole, see <https://docs.wxwidgets.org/3.0/classwx_app_console.html>. wxWidgets will automatically know what to do in that case. No recompilation of wxWidgets without the gui stuff is necessary.
Reply all
Reply to author
Forward
0 new messages