CH32V - Link-e, libusb error, Mac M3

Hi everyone, I’m encountering an error on my Mac M3 when trying to use the WCH Link-e debugger:

dyld[93222]: Library not loaded: /opt/homebrew/opt/libusb/lib/libusb-1.0.0.dylib
  Referenced from: <6BBF79F9-C1A5-38BD-85E2-6A75FB8D03BD> /Users/andersnelson/.platformio/packages/tool-openocd-riscv-wch/bin/openocd
  Reason: tried: '/opt/homebrew/opt/libusb/lib/libusb-1.0.0.dylib' (code signature in <8DD5BDC1-E490-325E-957C-BDD4B75715C8> '/opt/homebrew/Cellar/libusb/1.0.27/lib/libusb-1.0.0.dylib' not valid for use in process: mapping process and mapped file (non-platform) have different Team IDs)

Can anyone point me in the right direction to sort this?

Thanks!

I don’t have quite that combination, but I’m guessing the recipe is something like 'brew install libusb`

I have a different openocd for a different architecture, so the details aren’t interesting, but the demonstration is the lesson:

otool -L ~/.platformio/packages//tool-openocd-esp32/bin/openocd
~/.platformio/packages//tool-openocd-esp32/bin/openocd:
	/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1839.0.0)
	/System/Library/Frameworks/IOKit.framework/Versions/A/IOKit (compatibility version 1.0.0, current version 275.0.0)
	/usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1311.0.0)
	/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.11)

So my openocd doesn’t need libusb, but that’s how you can get MacOS to tell you what a binary (openocd) is linked against. It’s approximately ldd from more System V or GNU-ish OSes.

1 Like

Thanks @robertlipe for the insight. This solution worked for me:

Basically had to sign the executable and install an additional library.