0

我有一个使用 firebreath 框架编写的功能性插件。我需要为其添加 MTP 读写支持。

经过一番研究,我登陆了libmtp ( http://libmtp.sourceforge.net/ )。我下载了构建它的源代码,并且能够运行示例并读取/写入 MTP 设备。

接下来我尝试在我的 Firebreath 插件项目中添加使用这个库。我可以很好地编译,但我得到以下链接器错误。我已将包含 libusb.a 和 libiconv.a 文件的目录添加到我的搜索库路径中。

我也尝试过使用 Mac Ports 版本(sudo ports install libmtp +universal)

注意:要使用 libmtp,您需要安装 libiconv 和 libusb

这是我在 xcode 中遇到的链接器错误。

Undefined symbols for architecture i386:
  "_libiconv", referenced from:
      _ptp_unpack_string in libmtp.a(libmtp_la-ptp.o)
      _ptp_pack_string in libmtp.a(libmtp_la-ptp.o)
      _utf16_to_utf8 in libmtp.a(libmtp_la-unicode.o)
      _utf8_to_utf16 in libmtp.a(libmtp_la-unicode.o)
  "_libiconv_close", referenced from:
      _LIBMTP_Release_Device in libmtp.a(libmtp_la-libmtp.o)
  "_libiconv_open", referenced from:
      _LIBMTP_Open_Raw_Device_Uncached in libmtp.a(libmtp_la-libmtp.o)
  "_libusb_bulk_transfer", referenced from:
      _ptp_write_func in libmtp.a(libmtp_la-libusb1-glue.o)
      _ptp_usb_getdata in libmtp.a(libmtp_la-libusb1-glue.o)
      _ptp_read_func in libmtp.a(libmtp_la-libusb1-glue.o)
      _ptp_usb_event in libmtp.a(libmtp_la-libusb1-glue.o)
  "_libusb_claim_interface", referenced from:
      _init_ptp_usb in libmtp.a(libmtp_la-libusb1-glue.o)
  "_libusb_clear_halt", referenced from:
      _probe_device_descriptor in libmtp.a(libmtp_la-libusb1-glue.o)
      _close_usb in libmtp.a(libmtp_la-libusb1-glue.o)
  "_libusb_close", referenced from:
      _probe_device_descriptor in libmtp.a(libmtp_la-libusb1-glue.o)
      _close_usb in libmtp.a(libmtp_la-libusb1-glue.o)
  "_libusb_control_transfer", referenced from:
      _probe_device_descriptor in libmtp.a(libmtp_la-libusb1-glue.o)
      _ptp_usb_control_cancel_request in libmtp.a(libmtp_la-libusb1-glue.o)
      _init_ptp_usb in libmtp.a(libmtp_la-libusb1-glue.o)
      _close_usb in libmtp.a(libmtp_la-libusb1-glue.o)
  "_libusb_detach_kernel_driver", referenced from:
      _init_ptp_usb in libmtp.a(libmtp_la-libusb1-glue.o)
  "_libusb_free_config_descriptor", referenced from:
      _probe_device_descriptor in libmtp.a(libmtp_la-libusb1-glue.o)
      _configure_usb_device in libmtp.a(libmtp_la-libusb1-glue.o)
  "_libusb_free_device_list", referenced from:
      _configure_usb_device in libmtp.a(libmtp_la-libusb1-glue.o)
  "_libusb_get_bus_number", referenced from:
      _LIBMTP_Detect_Raw_Devices in libmtp.a(libmtp_la-libusb1-glue.o)
      _configure_usb_device in libmtp.a(libmtp_la-libusb1-glue.o)
  "_libusb_get_config_descriptor", referenced from:
      _probe_device_descriptor in libmtp.a(libmtp_la-libusb1-glue.o)
      _configure_usb_device in libmtp.a(libmtp_la-libusb1-glue.o)
  "_libusb_get_device", referenced from:
      _dump_usbinfo in libmtp.a(libmtp_la-libusb1-glue.o)
      _get_playlist_extension in libmtp.a(libmtp_la-libusb1-glue.o)
  "_libusb_get_device_address", referenced from:
      _LIBMTP_Detect_Raw_Devices in libmtp.a(libmtp_la-libusb1-glue.o)
      _configure_usb_device in libmtp.a(libmtp_la-libusb1-glue.o)
  "_libusb_get_device_descriptor", referenced from:
      _probe_device_descriptor in libmtp.a(libmtp_la-libusb1-glue.o)
      _LIBMTP_Detect_Raw_Devices in libmtp.a(libmtp_la-libusb1-glue.o)
      _dump_usbinfo in libmtp.a(libmtp_la-libusb1-glue.o)
      _get_playlist_extension in libmtp.a(libmtp_la-libusb1-glue.o)
      _configure_usb_device in libmtp.a(libmtp_la-libusb1-glue.o)
  "_libusb_get_device_list", referenced from:
      _LIBMTP_Check_Specific_Device in libmtp.a(libmtp_la-libusb1-glue.o)
      _LIBMTP_Detect_Raw_Devices in libmtp.a(libmtp_la-libusb1-glue.o)
      _configure_usb_device in libmtp.a(libmtp_la-libusb1-glue.o)
  "_libusb_get_string_descriptor_ascii", referenced from:
      _probe_device_descriptor in libmtp.a(libmtp_la-libusb1-glue.o)
  "_libusb_init", referenced from:
      _LIBMTP_Check_Specific_Device in libmtp.a(libmtp_la-libusb1-glue.o)
      _LIBMTP_Detect_Raw_Devices in libmtp.a(libmtp_la-libusb1-glue.o)
      _configure_usb_device in libmtp.a(libmtp_la-libusb1-glue.o)
  "_libusb_kernel_driver_active", referenced from:
      _probe_device_descriptor in libmtp.a(libmtp_la-libusb1-glue.o)
      _dump_usbinfo in libmtp.a(libmtp_la-libusb1-glue.o)
      _init_ptp_usb in libmtp.a(libmtp_la-libusb1-glue.o)
  "_libusb_open", referenced from:
      _probe_device_descriptor in libmtp.a(libmtp_la-libusb1-glue.o)
      _init_ptp_usb in libmtp.a(libmtp_la-libusb1-glue.o)
  "_libusb_release_interface", referenced from:
      _configure_usb_device in libmtp.a(libmtp_la-libusb1-glue.o)
      _close_usb in libmtp.a(libmtp_la-libusb1-glue.o)
  "_libusb_reset_device", referenced from:
      _configure_usb_device in libmtp.a(libmtp_la-libusb1-glue.o)
      _close_usb in libmtp.a(libmtp_la-libusb1-glue.o)
  "_libusb_set_debug", referenced from:
      _LIBMTP_Check_Specific_Device in libmtp.a(libmtp_la-libusb1-glue.o)
      _LIBMTP_Detect_Raw_Devices in libmtp.a(libmtp_la-libusb1-glue.o)
      _configure_usb_device in libmtp.a(libmtp_la-libusb1-glue.o)
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
4

1 回答 1

1

它不仅会自动链接那些其他库......您需要将其他库实际添加到您的 target_link_libraries 语句中。

于 2013-07-10T06:14:11.997 回答