Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FindLibudev: Link hidapi and libusb with libudev in static builds on Linux #12294

Merged
merged 3 commits into from
Nov 13, 2023

Conversation

fwcd
Copy link
Member

@fwcd fwcd commented Nov 12, 2023

Follow-up to the other static linking PRs (#12291, #12292), some of the hidapi-related dependencies have a dependency on libudev that we'll have to link in explicitly in static builds (see e.g. this build):

Click to see full linker error
/usr/bin/ld: /home/runner/work/m1xxx/m1xxx/vcpkg/installed/x64-linux/lib/libhidapi-hidraw.a(hid.c.o): in function `create_device_info_for_device':
hid.c:(.text+0x449): undefined reference to `udev_device_get_syspath'
/usr/bin/ld: hid.c:(.text+0x456): undefined reference to `udev_device_get_devnode'
/usr/bin/ld: hid.c:(.text+0x46c): undefined reference to `udev_device_get_parent_with_subsystem_devtype'
/usr/bin/ld: hid.c:(.text+0x48e): undefined reference to `udev_device_get_sysattr_value'
/usr/bin/ld: hid.c:(.text+0x9bf): undefined reference to `udev_device_get_parent_with_subsystem_devtype'
/usr/bin/ld: hid.c:(.text+0x9da): undefined reference to `udev_device_get_sysattr_value'
/usr/bin/ld: hid.c:(.text+0x9f5): undefined reference to `udev_device_get_sysattr_value'
/usr/bin/ld: hid.c:(.text+0xa18): undefined reference to `udev_device_get_sysattr_value'
/usr/bin/ld: hid.c:(.text+0xa47): undefined reference to `udev_device_get_parent_with_subsystem_devtype'
/usr/bin/ld: hid.c:(.text+0xa5f): undefined reference to `udev_device_get_sysattr_value'
/usr/bin/ld: /home/runner/work/m1xxx/m1xxx/vcpkg/installed/x64-linux/lib/libhidapi-hidraw.a(hid.c.o): in function `hid_enumerate':
hid.c:(.text+0xeb6): undefined reference to `udev_new'
/usr/bin/ld: hid.c:(.text+0xecc): undefined reference to `udev_enumerate_new'
/usr/bin/ld: hid.c:(.text+0xee3): undefined reference to `udev_enumerate_add_match_subsystem'
/usr/bin/ld: hid.c:(.text+0xeeb): undefined reference to `udev_enumerate_scan_devices'
/usr/bin/ld: hid.c:(.text+0xef3): undefined reference to `udev_enumerate_get_list_entry'
/usr/bin/ld: hid.c:(.text+0xf3a): undefined reference to `udev_list_entry_get_name'
/usr/bin/ld: hid.c:(.text+0xfe7): undefined reference to `udev_device_new_from_syspath'
/usr/bin/ld: hid.c:(.text+0x1004): undefined reference to `udev_device_unref'
/usr/bin/ld: hid.c:(.text+0x100c): undefined reference to `udev_list_entry_get_next'
/usr/bin/ld: hid.c:(.text+0x1022): undefined reference to `udev_enumerate_unref'
/usr/bin/ld: hid.c:(.text+0x102a): undefined reference to `udev_unref'
/usr/bin/ld: hid.c:(.text+0x10bd): undefined reference to `udev_enumerate_unref'
/usr/bin/ld: hid.c:(.text+0x10c5): undefined reference to `udev_unref'
/usr/bin/ld: /home/runner/work/m1xxx/m1xxx/vcpkg/installed/x64-linux/lib/libhidapi-hidraw.a(hid.c.o): in function `hid_get_device_info':
hid.c:(.text+0x183c): undefined reference to `udev_new'
/usr/bin/ld: hid.c:(.text+0x185a): undefined reference to `udev_device_new_from_devnum'
/usr/bin/ld: hid.c:(.text+0x187a): undefined reference to `udev_device_unref'
/usr/bin/ld: hid.c:(.text+0x1882): undefined reference to `udev_unref'
/usr/bin/ld: /home/runner/work/m1xxx/m1xxx/vcpkg/installed/x64-linux/lib/libusb-1.0.a(linux_udev.o): in function `udev_hotplug_event':
linux_udev.c:(.text+0x2c): undefined reference to `udev_device_get_action'
/usr/bin/ld: linux_udev.c:(.text+0x5c): undefined reference to `udev_device_get_devnode'
/usr/bin/ld: linux_udev.c:(.text+0x6c): undefined reference to `udev_device_get_sysname'
/usr/bin/ld: linux_udev.c:(.text+0xa2): undefined reference to `udev_device_unref'
/usr/bin/ld: /home/runner/work/m1xxx/m1xxx/vcpkg/installed/x64-linux/lib/libusb-1.0.a(linux_udev.o): in function `linux_udev_event_thread_main':
linux_udev.c:(.text+0x247): undefined reference to `udev_monitor_receive_device'
/usr/bin/ld: /home/runner/work/m1xxx/m1xxx/vcpkg/installed/x64-linux/lib/libusb-1.0.a(linux_udev.o): in function `linux_udev_start_event_monitor':
linux_udev.c:(.text+0x2f6): undefined reference to `udev_new'
/usr/bin/ld: linux_udev.c:(.text+0x315): undefined reference to `udev_monitor_new_from_netlink'
/usr/bin/ld: linux_udev.c:(.text+0x33b): undefined reference to `udev_monitor_filter_add_match_subsystem_devtype'
/usr/bin/ld: linux_udev.c:(.text+0x34f): undefined reference to `udev_monitor_enable_receiving'
/usr/bin/ld: linux_udev.c:(.text+0x363): undefined reference to `udev_monitor_get_fd'
/usr/bin/ld: linux_udev.c:(.text+0x480): undefined reference to `udev_monitor_unref'
/usr/bin/ld: linux_udev.c:(.text+0x4a1): undefined reference to `udev_unref'
/usr/bin/ld: /home/runner/work/m1xxx/m1xxx/vcpkg/installed/x64-linux/lib/libusb-1.0.a(linux_udev.o): in function `linux_udev_stop_event_monitor':
linux_udev.c:(.text+0x5b0): undefined reference to `udev_monitor_unref'
/usr/bin/ld: linux_udev.c:(.text+0x5d1): undefined reference to `udev_unref'
/usr/bin/ld: /home/runner/work/m1xxx/m1xxx/vcpkg/installed/x64-linux/lib/libusb-1.0.a(linux_udev.o): in function `linux_udev_scan_devices':
linux_udev.c:(.text+0x63d): undefined reference to `udev_enumerate_new'
/usr/bin/ld: linux_udev.c:(.text+0x65d): undefined reference to `udev_enumerate_add_match_subsystem'
/usr/bin/ld: linux_udev.c:(.text+0x673): undefined reference to `udev_enumerate_add_match_property'
/usr/bin/ld: linux_udev.c:(.text+0x67b): undefined reference to `udev_enumerate_scan_devices'
/usr/bin/ld: linux_udev.c:(.text+0x683): undefined reference to `udev_enumerate_get_list_entry'
/usr/bin/ld: linux_udev.c:(.text+0x6a4): undefined reference to `udev_list_entry_get_name'
/usr/bin/ld: linux_udev.c:(.text+0x6bd): undefined reference to `udev_device_new_from_syspath'
/usr/bin/ld: linux_udev.c:(.text+0x6c8): undefined reference to `udev_device_get_devnode'
/usr/bin/ld: linux_udev.c:(.text+0x6d8): undefined reference to `udev_device_get_sysname'
/usr/bin/ld: linux_udev.c:(.text+0x721): undefined reference to `udev_device_unref'
/usr/bin/ld: linux_udev.c:(.text+0x729): undefined reference to `udev_list_entry_get_next'
/usr/bin/ld: linux_udev.c:(.text+0x73f): undefined reference to `udev_enumerate_unref'
/usr/bin/ld: /home/runner/work/m1xxx/m1xxx/vcpkg/installed/x64-linux/lib/libusb-1.0.a(linux_udev.o): in function `linux_udev_hotplug_poll':
linux_udev.c:(.text+0x7c8): undefined reference to `udev_monitor_receive_device'

Note that libudev itself will likely still have to be linked dynamically, since it is part of the systemd libraries.

@fwcd
Copy link
Member Author

fwcd commented Nov 12, 2023

Hm, maybe we should add a new Findudev module, since we may also have to link this in LibUSB...

@fwcd fwcd force-pushed the linux-static-hidapi-udev branch from 82b0fb3 to 573c269 Compare November 12, 2023 20:32
@fwcd fwcd changed the title Findhidapi: Link udev in static builds on Linux FindUdev: Link hidapi and libusb with udev in static builds on Linux Nov 12, 2023
@fwcd fwcd force-pushed the linux-static-hidapi-udev branch from 573c269 to 7b032e0 Compare November 12, 2023 20:57
@fwcd fwcd force-pushed the linux-static-hidapi-udev branch from 7b032e0 to acac65e Compare November 12, 2023 21:29
@fwcd fwcd changed the title FindUdev: Link hidapi and libusb with udev in static builds on Linux FindLibudev: Link hidapi and libusb with libudev in static builds on Linux Nov 12, 2023
@fwcd fwcd marked this pull request as ready for review November 12, 2023 22:08
@fwcd
Copy link
Member Author

fwcd commented Nov 12, 2023

I've named the module Libudev since both the pkgconfig and the header are named libudev (rather than just udev) and added a missing find_path. This seems to work, no more udev errors, therefore I'll mark this as ready for review!

Copy link
Member

@daschuer daschuer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@daschuer daschuer merged commit 3252675 into mixxxdj:main Nov 13, 2023
10 checks passed
@fwcd fwcd deleted the linux-static-hidapi-udev branch November 13, 2023 12:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants