Pre-built openocd binary for OSX is built against non-existent Homebrew libraries

As an experiment, I thought it would be interesting to try to avoid building openocd from source. By pulling links out of the package_sifive_index.json file - which is intended for use by the Arduino IDE - I was able to download a pre-built Darwin binary. (I’ve written a page about this here.)

However, when I tried to run openocd, it failed. otool -L showed that it had been linked against libusb binaries in /usr/local/opt/, which suggested that the builder had used Homebrew and hadn’t “sanitized” the build environment to prevent these local-to-their-setup dependencies from creeping into the built binary.

I don’t use Homebrew (I prefer Nix and nixpkgs!) and I was able, using some clever symlinking, to get around this. But it would be nice if openocd statically linked to libusb. I don’t think it would bloat the executable too terribly, and would avoid these hurdles for others. :wink:

I thought of making these comments in the sifive/openocd/ issue tracker on GitHub, but because the trouble is with a pre-built binary and not the source that didn’t seem totally appropriate.

I have a quite elaborate procedure to build multi-platform binaries for OpenOCD, as part of the GNU ARM Eclipse project.

When running on macOS, the script creates standalone win32/win64, deb32/deb64 and osx64 binaries.

The procedure is documented at:

Perhaps we can merge the source changes into my repository and maintain a single version of the project, with a single set of binaries, or use a similar script to generate the binaries.


You could raise it as an issue against the ‘Cinco’ repository :

Our intention was to include all necessary packages as you described, so we can look into how the one for OpenOCD was built.

I opened issues for both the OSX and Linux binaries. The Linux binaries have the same problem, essentially…

1 Like