xmake-io / xmake

🔥 A cross-platform build utility based on Lua
https://xmake.io
Apache License 2.0
9.82k stars 774 forks source link

Link order issue with libusb #1885

Closed SirLynix closed 2 years ago

SirLynix commented 2 years ago

Describe the bug

I have a CI failing because of a linking order issue with one of the dep of libusb (udev).

Here's the run: https://github.com/SirLynix/obs-kinect/runs/4413978328

We can see that it test correctly libusb (usb-1.0 then udev):

checking for c includes(libusb-1.0/libusb.h) checking for c funcs(libusb_init) checking for c links(usb-1.0, udev, pthread) checking for c snippet(has_cfuncs) => install libusb v1.0.24 .. ok

But with one dependency that uses libusb (libfreenect), it fails: https://github.com/SirLynix/obs-kinect/runs/4413978328?check_suite_focus=true#step:11:3192

checking for c includes(libfreenect/libfreenect.h) checking for c funcs(freenect_init) checking for c links(freenect, udev, usb-1.0, pthread) checking for c snippet(has_cfuncs) error: /usr/bin/ld: /home/runner/.config/.xmake/packages/l/libusb/v1.0.24/29cd4120aa6849118d1fbd13749847f7/lib/libusb-1.0.a(linux_udev.o): in function linux_udev_start_event_monitor': linux_udev.c:(.text+0xb4): undefined reference toudev_new'

udev got in front of usb-1.0, which fails as usb-1.0 requires udev.

I don't know why that happens, and I can't reproduce it on my computer where the link order is correct:

> checking for c includes(libfreenect/libfreenect.h)
> checking for c funcs(freenect_init)
> checking for c links(freenect, usb-1.0, udev, pthread)
> checking for c snippet(has_cfuncs)
  => install libfreenect v0.6.2 .. ok

Expected behavior

That the link order is correct on the CI.

Related Environment

waruqi commented 2 years ago

I have fixed it.

SirLynix commented 2 years ago

I can confirm it works, thanks!