Hi all,
I have been working for some time on allowing fully static linking of an areaDetector driver I wrote some time ago:
At first, I used $(PROD_NAME)_SYS_LIBS to link to the support library I used for communicating with the device, but
I would like to change this to $(PROD_NAME)_LIBS since it would be my understanding that this would mean that the driver application
could be built entirely statically, making it more portable since then the support library wouldn't have to be installed and in the system path
during runtime.
When using SYS_LIBS, the driver library and IOC application build without issue, however, when I change to just LIBS, the library still
compiles OK, but I get many undefined reference errors when compiling the App:
/epics/src/support/areaDetector/ADUVC/lib/linux-x86_64/libuvc.a(ctrl-gen.c.o): In function `uvc_get_scanning_mode':
ctrl-gen.c:(.text+0x5b): undefined reference to `libusb_control_transfer'
/epics/src/support/areaDetector/ADUVC/lib/linux-x86_64/libuvc.a(ctrl-gen.c.o): In function `uvc_set_scanning_mode':
ctrl-gen.c:(.text+0xea): undefined reference to `libusb_control_transfer'
/epics/src/support/areaDetector/ADUVC/lib/linux-x86_64/libuvc.a(ctrl-gen.c.o): In function `uvc_get_ae_mode':
ctrl-gen.c:(.text+0x17b): undefined reference to `libusb_control_transfer'
/epics/src/support/areaDetector/ADUVC/lib/linux-x86_64/libuvc.a(ctrl-gen.c.o): In function `uvc_set_ae_mode':
ctrl-gen.c:(.text+0x20a): undefined reference to `libusb_control_transfer'
/epics/src/support/areaDetector/ADUVC/lib/linux-x86_64/libuvc.a(ctrl-gen.c.o): In function `uvc_get_ae_priority':
ctrl-gen.c:(.text+0x29b): undefined reference to `libusb_control_transfer'
/epics/src/support/areaDetector/ADUVC/lib/linux-x86_64/libuvc.a(ctrl-gen.c.o):ctrl-gen.c:(.text+0x32a): more undefined references to `libusb_control_transfer' follow
/epics/src/support/areaDetector/ADUVC/lib/linux-x86_64/libuvc.a(device.c.o): In function `uvc_free_device_info':
device.c:(.text+0x4c6): undefined reference to `libusb_free_config_descriptor'
/epics/src/support/areaDetector/ADUVC/lib/linux-x86_64/libuvc.a(device.c.o): In function `uvc_get_device_descriptor':
device.c:(.text+0x58d): undefined reference to `libusb_get_device_descriptor'
device.c:(.text+0x5f1): undefined reference to `libusb_open'
device.c:(.text+0x618): undefined reference to `libusb_get_string_descriptor_ascii'
device.c:(.text+0x640): undefined reference to `libusb_get_string_descriptor_ascii'
device.c:(.text+0x668): undefined reference to `libusb_get_string_descriptor_ascii'
device.c:(.text+0x683): undefined reference to `libusb_close'
/epics/src/support/areaDetector/ADUVC/lib/linux-x86_64/libuvc.a(device.c.o): In function `uvc_get_device_list':
device.c:(.text+0x711): undefined reference to `libusb_get_device_list'
device.c:(.text+0x769): undefined reference to `libusb_get_config_descriptor'
device.c:(.text+0x77d): undefined reference to `libusb_get_device_descriptor'
device.c:(.text+0x81c): undefined reference to `libusb_free_config_descriptor'
device.c:(.text+0x83c): undefined reference to `libusb_free_device_list'
device.c:(.text+0x969): undefined reference to `libusb_free_config_descriptor'
device.c:(.text+0x996): undefined reference to `libusb_ref_device'
/epics/src/support/areaDetector/ADUVC/lib/linux-x86_64/libuvc.a(device.c.o): In function `uvc_find_device':
device.c:(.text+0xac2): undefined reference to `libusb_get_device_descriptor'
device.c:(.text+0xb09): undefined reference to `libusb_unref_device'
device.c:(.text+0xb51): undefined reference to `libusb_open
...
The support library in use depends on libusb and libjpeg, both of which are found during the cmake build for said library. It is built both statically and dynamically.
I ran nm on the static library, and I did see the libusb functrions listed:
U _GLOBAL_OFFSET_TABLE_
0000000000000000 d isight_tag.6062
U libusb_alloc_transfer
U libusb_cancel_transfer
U libusb_control_transfer
U libusb_free_ss_endpoint_companion_descriptor
U libusb_free_transfer
U libusb_get_ss_endpoint_companion_descriptor
U libusb_set_interface_alt_setting
U libusb_submit_transfer
...
It is clear to me that this is some error I have in the linking process/configuration, but I can't seem to figure out what
specifically it could be. I have tried adding libusb to the LIBS for the ioc application (copying the statically compiled library to
ADUVC/lib/linux-x86_64), but this gave me the same error, and the same when I added libusb to SYS_LIBS.
I have had similar issues when trying to get a static build of OpenCV to link against an areaDetector application -
it works fine when building the intermediate libraries (plugins, driver lib), but when building the final IOC application I got undefined reference errors.
If anyone has an idea on what I should change, it would be much appreciated.
Thanks!
Jakub Wlodek
|