JavaEar 专注于收集分享传播有价值的技术资料

brew install libusb linking failed

I am installing libusb with brew in my Mac

brew install libusb

The linking step failed as below

Error: The `brew link` step did not complete successfully The formula built, but is not symlinked into /usr/local 

Could not symlink lib/libusb-1.0.0.dylib 

Target /usr/local/lib/libusb-1.0.0.dylib already exists. 

You may want to remove it:   rm '/usr/local/lib/libusb-1.0.0.dylib'

To force the link and overwrite all conflicting files:   brew link
--overwrite libusb

So I removed the existing libusb with

sudo rm '/usr/local/lib/libusb-1.0.0.dylib'

and then did a link

brew link --overwrite libusb

The linking doesn't work, shows error below

Error: Could not symlink lib/libusb-1.0.0.dylib

/usr/local/lib is not writable.

If I try

sudo brew link --overwrite libusb

instead, that doesn't work either. What am I missing?

I am using OSX El Capitan version 10.11.4 (15E65)


  1. If things seem not to work with homebrew, my general strategy is first to try:

    brew doctor

    and do whatever the good doctor recommends.

    If that fails, I tend to uninstall things, normally using --force which really does a good clean-up and removes old versions. So, in your case:

    brew rm libusb --force

    Then re-install the "unhappy" package. So, in your case:

    brew install libusb

    In answer to your new question in the comments. Your installation looks correct because libusb isn't an executable program - it is just a library without any associated command-line tools - so it won't show up when you run which libusb.

    You can see the constituent parts of the package with this command:

    brew ls libusb
    /usr/local/Cellar/libusb/1.0.20/lib/ (2 other files)

    And, as you can see, there is no stand-alone executable program in /usr/local/bin called libusb, there are just

    • libusb.h - a C header file you would compile against
    • libusb...dylib - a dynamic library you would link against
    • libusb...pc - which supplies the info for the pkgconfig tool

    So, if you wanted to compile and link an application against libusb, you would run pkg-config like this to find out the "Include path" and linker details

    pkg-config --cflags --libs libusb
    -I/usr/local/Cellar/libusb-compat/0.1.5/include      \ 
    -I/usr/local/Cellar/libusb/1.0.20/include/libusb-1.0 \

    which means your compilation command would look like this:

    gcc yourApp.c $(pkg-config --cflags --libs libusb) -o yourApp