what is the difference in 2 libraries? Which one is prefered for production apps? Why is there significantly different set of dependencies while installing?
1 Answers
There is only one libnotify library. I assume you're asking about the deb packages libnotify-bin and libnotify-dev.
If so, the difference is very simple: the library packages with -dev
suffix contain development files for the library, while packages with -bin
suffix may contain some compiled binaries and utilities. To learn more about the contents of these packages, see the list of installed files for dev and bin packages.
As you are using c++
tag, I assume you need this library to send notifications from your application. In this case you should use libnotify-dev
package which provides C API for the libnotify. libnotify-bin
contains the notify-send
binary which is more suitable for use in shell scripts.
Here is the minimal example using the library:
#include <libnotify/notify.h>
int main()
{
notify_init("Test");
NotifyNotification* n = notify_notification_new ("title", "text", 0);
notify_notification_set_timeout(n, 3000);
if (!notify_notification_show(n, 0)) {
return -1;
}
return 0;
}
Install the libnotify-dev
package and compile the example with the following command:
g++ test.cpp `pkg-config --cflags --libs libnotify`
Then run the result file to see the notification.

- 1,526
- 2
- 8
- 20
-
Thanks. This is what I wanted to know since I am trying to use it from my c++ app which runs as daemon, is there any other thing I need to take care of in this case to show notification? Also if there is cmake guide to include this package with dependencies. I was getting "glib.h header not found" error when I followed this the way desccribed in the link https://github.com/WebKit/webkit/blob/main/Source/cmake/FindLibNotify.cmake. – vkg May 18 '21 at 08:56
-
@veerendragupta I think this is enough to get you started with libnotify. May be you will be interested in some additional libraries that provide a high level C++ API for the notifications, described here: https://wiki.archlinux.org/title/Desktop_notifications#C++. To be honest, I never used them and prefer to write my own wrappers around libnotify. – jubnzv May 18 '21 at 09:04
-
Error with the glib header.the h is probably due to the fact that your build system can't find glib. I think you should add GLib to the cmake project as is described here: https://stackoverflow.com/questions/2730135/how-do-i-link-gtk-library-more-easily-with-cmake-in-windows/5105523#5105523. – jubnzv May 18 '21 at 09:06
-
Thanks..it doesn't send notifiation to other users. how can I use it to run from a daemon running as root user & notify all the users. – vkg May 19 '21 at 15:25