wayland-push-to-talk-fix icon indicating copy to clipboard operation
wayland-push-to-talk-fix copied to clipboard

undefined reference to `libevdev_new_from_fd'

Open JonasOlson opened this issue 2 years ago • 5 comments

On Ubuntu 22.04.1.

Install dependencies:

wayland-push-to-talk-fix$ sudo apt install libevdev-dev libxdo-dev
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
libevdev-dev is already the newest version (1.12.1+dfsg-1).
libxdo-dev is already the newest version (1:3.20160805.1-4).
0 upgraded, 0 newly installed, 0 to remove and 8 not upgraded.

Attempt build:

wayland-push-to-talk-fix$ make
g++ -Os -levdev  -levdev -lxdo  push-to-talk.cpp   -o push-to-talk
/usr/bin/ld: /tmp/ccGcaImP.o: in function `main':
push-to-talk.cpp:(.text.startup+0xa4): undefined reference to `libevdev_new_from_fd'
/usr/bin/ld: push-to-talk.cpp:(.text.startup+0xc7): undefined reference to `libevdev_get_name'
/usr/bin/ld: push-to-talk.cpp:(.text.startup+0xee): undefined reference to `libevdev_get_id_product'
/usr/bin/ld: push-to-talk.cpp:(.text.startup+0xfc): undefined reference to `libevdev_get_id_vendor'
/usr/bin/ld: push-to-talk.cpp:(.text.startup+0x10a): undefined reference to `libevdev_get_id_bustype'
/usr/bin/ld: push-to-talk.cpp:(.text.startup+0x144): undefined reference to `libevdev_has_event_code'
/usr/bin/ld: push-to-talk.cpp:(.text.startup+0x164): undefined reference to `xdo_new'
/usr/bin/ld: push-to-talk.cpp:(.text.startup+0x19d): undefined reference to `libevdev_next_event'
/usr/bin/ld: push-to-talk.cpp:(.text.startup+0x1d0): undefined reference to `xdo_send_keysequence_window_down'
/usr/bin/ld: push-to-talk.cpp:(.text.startup+0x1d7): undefined reference to `xdo_send_keysequence_window_up'
/usr/bin/ld: push-to-talk.cpp:(.text.startup+0x1e1): undefined reference to `xdo_free'
/usr/bin/ld: push-to-talk.cpp:(.text.startup+0x1eb): undefined reference to `libevdev_free'
collect2: error: ld returned 1 exit status
make: *** [<builtin>: push-to-talk] Error 1

Toolchain versions:

wayland-push-to-talk-fix$ g++ --version
g++ (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

wayland-push-to-talk-fix$ /usr/bin/ld --version
GNU ld (GNU Binutils for Ubuntu) 2.38
Copyright (C) 2022 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) a later version.
This program has absolutely no warranty.

JonasOlson avatar Feb 11 '23 22:02 JonasOlson

same here on Ubuntu 22.04.

ViBE-HU avatar May 16 '23 22:05 ViBE-HU

This compiles fine on Fedora 38 but not on Ubuntu 22.04 LTS where it has the above mentioned linking errors. If I add one line to the Makefile it works for both operating systems:

$ git diff Makefile
diff --git a/Makefile b/Makefile
index e1d73ae..fdb9867 100644
--- a/Makefile
+++ b/Makefile
@@ -6,6 +6,7 @@ LDFLAGS=`pkg-config --libs libevdev` -lxdo
 all: push-to-talk
 
 push-to-talk: push-to-talk.cpp
+       $(CXX) push-to-talk.cpp $(CXXFLAGS) $(LDFLAGS) -o push-to-talk
 
 clean:
        rm -f push-to-talk

AusMatt avatar Sep 17 '23 01:09 AusMatt

This compiles fine on Fedora 38 but not on Ubuntu 22.04 LTS where it has the above mentioned linking errors. If I add one line to the Makefile it works for both operating systems:

$ git diff Makefile
diff --git a/Makefile b/Makefile
index e1d73ae..fdb9867 100644
--- a/Makefile
+++ b/Makefile
@@ -6,6 +6,7 @@ LDFLAGS=`pkg-config --libs libevdev` -lxdo
 all: push-to-talk
 
 push-to-talk: push-to-talk.cpp
+       $(CXX) push-to-talk.cpp $(CXXFLAGS) $(LDFLAGS) -o push-to-talk
 
 clean:
        rm -f push-to-talk

How exactly did you insert it? When I do it how I think you did, make tells me it's missing a separator in line 9. That's my Makefile:

CXXFLAGS=-Os `pkg-config --cflags libevdev`
LDFLAGS=`pkg-config --libs libevdev` -lxdo

.PHONY: all clean

all: push-to-talk

push-to-talk: push-to-talk.cpp
       $(CXX) push-to-talk.cpp $(CXXFLAGS) $(LDFLAGS) -o push-to-talk

clean:
	rm -f push-to-talk

install:
	install -m 755 push-to-talk /usr/bin
	install -m 644 push-to-talk.desktop /etc/xdg/autostart

Artim96 avatar May 27 '24 09:05 Artim96

This compiles fine on Fedora 38 but not on Ubuntu 22.04 LTS where it has the above mentioned linking errors. If I add one line to the Makefile it works for both operating systems:

$ git diff Makefile
diff --git a/Makefile b/Makefile
index e1d73ae..fdb9867 100644
--- a/Makefile
+++ b/Makefile
@@ -6,6 +6,7 @@ LDFLAGS=`pkg-config --libs libevdev` -lxdo
 all: push-to-talk
 
 push-to-talk: push-to-talk.cpp
+       $(CXX) push-to-talk.cpp $(CXXFLAGS) $(LDFLAGS) -o push-to-talk
 
 clean:
        rm -f push-to-talk

How exactly did you insert it? When I do it how I think you did, make tells me it's missing a separator in line 9. That's my Makefile:

CXXFLAGS=-Os `pkg-config --cflags libevdev`
LDFLAGS=`pkg-config --libs libevdev` -lxdo

.PHONY: all clean

all: push-to-talk

push-to-talk: push-to-talk.cpp
       $(CXX) push-to-talk.cpp $(CXXFLAGS) $(LDFLAGS) -o push-to-talk

clean:
	rm -f push-to-talk

install:
	install -m 755 push-to-talk /usr/bin
	install -m 644 push-to-talk.desktop /etc/xdg/autostart

The whitespace before "$(CXX)" is a tab character. As it is for all the indents. I still use this today and it works. I use it by first prepping my sudo timer with say "sudo ls", I then run this sequence: cd ~/git/wayland-push-to-talk-fix/; sudo -u $USER -g input nohup ./push-to-talk /dev/input/by-id/usb-Logitech_G512_RGB_MECHANICAL_GAMING_KEYBOARD_0A7431423932-event-kbd </dev/null >/dev/null 2>&1 & I can then exit that shell and get down to gaming. Good luck!

AusMatt avatar May 27 '24 10:05 AusMatt

Getting the same. Author, please fix.

Maelstromeous avatar Jan 09 '25 01:01 Maelstromeous