-
Notifications
You must be signed in to change notification settings - Fork 770
Link local libusb statically on Linux/Mac #283
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
Conversation
@tikiking1 Does this PR work for your libfreenect2-git and pyfreenect2? Do they work correctly with static libusb? |
The Arch package builds fine, I'm updating it now. I don't actually have a Kinect 2 with me right now, but Protonect doesn't immediately segfault, so that's encouraging. |
And pyfreenect2 builds fine, but gets |
It's a bug. Thanks for the catch. |
libusb-1.0.a must come before -ludev, otherwise libudev is ignored by linker because of lack of dependency.
The bug was caused by reversing the link order of libusb. Can you update and try again? (The reason this bug was not detected by running Protonect is because Protonect pulled in libudev via some other libraries, while libfreenect2.so itself did not.) |
OK, it works now (in terms of getting an error because I don't have a Kinect with me, rather than because of a linking issue) |
Is there a timeline for when this and #284 will get merged? |
Not really, although I'm hoping I'll get around to it sometime next week. Problem is that there may still be some interference with #292. |
#292 is fairly easy to code up. The issue is a decision has to be made. |
I start to think embedded static libusb in libfreenect2 is a bad idea. The hack of messing with export symbols was not a good idea from the outset and can easily break. Besides, it is really not up to libfreenect2 to decide where to install libusb, or to embed it. For packagers, I think the best option is to carry a separate libusb.so in a private directory of the package you want to release and change RPATH of libfreenect2 to that directory. |
I have created a patch for specifying custom RPATH https://github.com/xlz/libfreenect2/commit/7a4708fa03d528ff9339c2c7034515e44861561a. It is expected to be part of a future PR soon. |
Following discussions in #281.
This builds libusb-1.0.a into libfreenect2.so.
An issue with that is libfreenect2.so will export symbols that belong to libusb-1.0, then the users can't link libfreenect2 with anything that links with the system libusb-1.0 (symbol conflicts).
This works around the above issue by using GCC linker flag
--exclude-libs,libusb-1.0.a
. On Mac OSX,ld64
does not support such operation, with only one solution: generate all symbols, remove_libusb_*
symbols, and specify non-libusb symbols with-exported_symbols_list,nolibusb.sym
.If anyone has better approach, please comment below. Static linking on Windows is a seperate PR.