Thursday, December 28, 2023

A Small Issue To Compile Usb-notify Program 2023

A Small Issue To Compile Usb-notify Program 2023

undefined reference to notify_notification_new

I like the usb-notify program a lot. This small little program displays a notification on the Linux desktop when a USB device is plugged in.

To compile I need libnotify-dev, libudev-dev package.

$ git clone https://github.com/wcampbell0x2a/usb-notify
$ cd usb-notify
$ make
⇒ bin/usb-notify

Note: Need notification-daemon running to show the notification.

It should just compile and be successful. If it doesn't it is just a small issue, but this small issue took me 1.5 days to try out many other ways, for example trying to recompile the dependency libraries.

This is what I get:

$ gcc -ansi -pedantic -g -std=c99 -W -Wextra -Wall \
`pkg-config --cflags --libs libnotify` \
-o bin/usb-notify src/usb-notify.o -ludev

undefined reference to `notify_notification_new'

Keep story short, there is no missing libnotify, as 'pkg-config --libs libnotify' will return '-lnotify' (refer to libnotify.a or libnotify.so), is just has to be put at the back of the compile statement:

$ gcc -o bin/usb-notify src/usb-notify.o -ludev `pkg-config --libs libnotify`

So you might just need to modify the Makefile will do.

No comments:

Post a Comment