earlephilhower / arduino-pico

Raspberry Pi Pico Arduino core, for all RP2040 boards
GNU Lesser General Public License v2.1
1.88k stars 394 forks source link

multiple definitions of functions ( tud_msc_write10_cb etc ) when compiling both Adafruit_TinyUSB.h and FatFSUSB.h #2227

Closed cyberboy666 closed 1 month ago

cyberboy666 commented 1 month ago

hello @earlephilhower and thanks so much for your work on this !

i have a question about whether it would be possible to run a project that compiles both Adafruit_TinyUSB.h and FatFSUSB.h libraries - i understand that it may not be possible to use both at same time, however for my __midi_controller__ project i was hoping i could implement a button that switched between:

i have these functions working individually however when i try to combine them i get compiler errors such as:

/home/timcaldwell/.platformio/packages/toolchain-rp2040-earlephilhower/bin/../lib/gcc/arm-none-eabi/12.3.0/../../../../arm-none-eabi/bin/ld: .pio/build/pico/libb54/FatFSUSB/FatFSUSB.cpp.o: in function `tud_msc_write10_cb':
FatFSUSB.cpp:(.text.tud_msc_write10_cb+0x0): multiple definition of `tud_msc_write10_cb'; .pio/build/pico/lib18b/Adafruit_TinyUSB_Arduino/arduino/msc/Adafruit_USBD_MSC.cpp.o:Adafruit_USBD_MSC.cpp:(.text.tud_msc_write10_cb+0x0): first defined here
/home/timcaldwell/.platformio/packages/toolchain-rp2040-earlephilhower/bin/../lib/gcc/arm-none-eabi/12.3.0/../../../../arm-none-eabi/bin/ld: .pio/build/pico/libb54/FatFSUSB/FatFSUSB.cpp.o: in function `tud_msc_scsi_cb':
FatFSUSB.cpp:(.text.tud_msc_scsi_cb+0x0): multiple definition of `tud_msc_scsi_cb'; .pio/build/pico/lib18b/Adafruit_TinyUSB_Arduino/arduino/msc/Adafruit_USBD_MSC.cpp.o:Adafruit_USBD_MSC.cpp:(.text.tud_msc_scsi_cb+0x0): first defined here

do you know if this should be possible in theory ? is there a recommended approach ? im happy to modify the source for my project if needed... was thinking about trying to add some namespaces or something but thought i would ask here first

thanks for your time tim

earlephilhower commented 1 month ago

No, this is not possible. You can either use the PicoSDK USB or Adafruit TinyUSB, not both. FatFSUSB requires the PicoSDK one. TinyUSB has predefined callbacks that need to be implemented and both the core and the Adafruit library define them hence the multiple definitions problem.

You might be able to finagle your own TinyUSB flash exporter app, though. The FatFSUSB library is pretty simple and you'd just need to translate the raw API calls to the Adafruit wrapped versions. Good luck!