1
votes

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
Try smacking it harder... brew rm libusb --force, brew install libusbMark Setchell
Also, if you are planning on using it to scan, be aware that Image Capture squats on the scanner and needs to be killed before you can scan. Oh, I may mention smacking and killing, but I'm not really a violent person ;-)Mark Setchell
@MarkSetchell after messing up brew and recovering, I did brew rm libusb --force, sudo brew install libusb (wo sudo was permission denied). Seemed to work wo error. Now if I do which libusb, it doesn't show anything. Does that mean libusb is still not linked?nad
I am having a similar problem. None of the suggestions helped-- the root of the problem seems to be that brew installs libusb as "libusb-1.0" (with the -1.0 appended to the file names and package names). I don't have a solution yet, but manually creating a non-1.0 version of the .pc file at least let pkg-config see it.samkass

1 Answers

7
votes

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/include/libusb-1.0/libusb.h
/usr/local/Cellar/libusb/1.0.20/lib/libusb-1.0.0.dylib
/usr/local/Cellar/libusb/1.0.20/lib/pkgconfig/libusb-1.0.pc
/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 \
-L/usr/local/Cellar/libusb

which means your compilation command would look like this:

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