PeterCxy / evdev-right-click-emulation

Implement Long-Press-to-Right-Click on Touchscreen Linux Devices with Xorg or Wayland
Do What The F*ck You Want To Public License
90 stars 32 forks source link

(solved) Program compiles on Raspbian 10 but not on Ubuntu 20.04 - ld cannot find symbols from libevdev #14

Closed compilebunny closed 2 years ago

compilebunny commented 3 years ago

The program compiled well on Raspbian 10 with the following evdev-related packages installed (apt list --installed | grep evdev)

libevdev-dev/oldstable,now 1.6.0+dfsg-1 armhf [installed] libevdev-doc/oldstable,now 1.6.0+dfsg-1 all [installed] libevdev-tools/oldstable,now 1.6.0+dfsg-1 armhf [installed] libevdev2/oldstable,now 1.6.0+dfsg-1 armhf [installed] python-evdev/oldstable,now 1.1.2+dfsg-1+b1 armhf [installed] python3-evdev/oldstable,now 1.1.2+dfsg-1+b1 armhf [installed,automatic]

But it fails on Ubuntu Mate 20.04 with the following evdev-related packages installed

libevdev-dev/focal-updates,now 1.9.0+dfsg-1ubuntu0.1 arm64 [installed] libevdev-doc/focal-updates,now 1.9.0+dfsg-1ubuntu0.1 all [installed] libevdev-tools/focal-updates,now 1.9.0+dfsg-1ubuntu0.1 arm64 [installed] libevdev2/focal-updates,now 1.9.0+dfsg-1ubuntu0.1 arm64 [installed] python3-libevdev/focal,now 0.5-1 all [installed] xserver-xorg-input-evdev-dbg/focal,now 1:2.10.6-1 arm64 [installed] xserver-xorg-input-evdev-dev-hwe-18.04/focal,now 3:14.5 arm64 [installed] xserver-xorg-input-evdev-dev/focal,now 1:2.10.6-1 all [installed] xserver-xorg-input-evdev-hwe-18.04-dbg/focal,now 3:14.5 arm64 [installed] xserver-xorg-input-evdev-hwe-18.04/focal,now 3:14.5 arm64 [installed] xserver-xorg-input-evdev/focal,now 1:2.10.6-1 arm64 [installed]

Compiling fails on linking with the following messages:

/usr/bin/ld: out/uinput.o: in function uinput_initialize': uinput.c:(.text+0x1c): undefined reference tolibevdev_new' /usr/bin/ld: uinput.c:(.text+0x30): undefined reference to `libevdev_set_name'

(etc...)

compilebunny commented 2 years ago

Solution:

In Makefile, "-levdev" should be moved to the end of the compilation command. Replace Makefile with the following

CC := gcc XFLAGS := -Wall -std=c11 -D_POSIX_C_SOURCE=199309L LIBRARIES := -levdev INCLUDES := -I/usr/include/libevdev-1.0 CFLAGS := $(XFLAGS) $(LIBRARIES) $(INCLUDES)

OUTDIR := out SOURCES := uinput.c input.c rce.c OBJS := $(SOURCES:%.c=$(OUTDIR)/%.o) TARGET := $(OUTDIR)/evdev-rce

.PHONY: all clean

$(OUTDIR)/%.o: %.c @mkdir -p $(OUTDIR) $(CC) -c $< -o $@ $(CFLAGS)

$(TARGET): $(OBJS) $(CC) $^ -o $@ $(CFLAGS)

all: $(TARGET) clean: rm -rf $(OUTDIR)