[sane-devel] sane-backend 1.0.27 USB broken on Mac with Homebrew

Olaf Meeuwissen paddy-hack at member.fsf.org
Thu Jul 27 12:01:19 UTC 2017

Hi Thomas,

schmo-fu writes:

> Hi Olaf,
> sorry for the long wait, but now i'm back at the machine with the scanner.

No problem.  I've been swamped with Real Work the last three days
anyways ;-)

> Am 24.07.17 um 14:09 schrieb Olaf Meeuwissen:
>> Try --with-usb=yes.  That really *should* bomb.
> I put '--with-usb=yes' into the formula, but that didn't stop the
> compilation. You find the log here:
> https://gist.github.com/anonymous/5ea27bd1a4c1f0baffebffe7aec0caf3

That has:

  checking for USB... no
  checking for USB... no
  checking usb.h usability... yes
  checking usb.h presence... yes
  checking for usb.h... yes
  checking for usb_interrupt_read in -lusb... yes
  checking lusb0_usb.h usability... no
  checking lusb0_usb.h presence... no
  checking for lusb0_usb.h... no

So it *does* find some usable USB support and hence won't bomb.  From
the comment in configure.ac, that first `yes` hints at a 10+ years old
libusb (or Windows version).  I *think* it found something from that
libusb-compat package.

>> From the config.log I see that there's probably a libusb-compat
>> installed somewhere.  I'd suggest to get rid of that (as far as SANE is
>> concerned) because libusb-1.x should be okay.
>> From that same file, I also gather there should be libusb*.pc files (or
>> similar) in
>>   /usr/local/opt/libusb/lib/pkgconfig
>> and
>>   /usr/local/opt/libusb-compat/lib/pkgconfig
>> Curious about what those have to say about libusb because, AFAIU, the
>> configure script should be looking at those before it decides there's
>> no USB support.
> i copied the contents of the two pc-files to this pad:
> https://codicill.us/pad/p/gist

I have zero idea about homebrew works but the paths of the *.pc files
themselves and the prefixes they list look highly suspicious.  That is,
the files live below /usr/local/opt/ but their prefix point below
/usr/local/Cellar/.  There may be some symlinks to make this all work,
magically, but to me it looks fishy.

If those *.pc files are found when running ./configure, that excerpt of
the ./configure output quoted above should reduce to just

  checking for USB... yes

and USB should work.  The ./configure script makes sure that pkg-config
(which deals with these *.pc files) is set up correctly for your build
environment before it tries to find the *.pc files.  From the initial
./configure output excerpt it very much looks like they are *not* found
at all.

> Then i force uninstalled libusb-compat.
> That stopped sane-find-scanner from working (See error-message at the
> end of the pad). So this looks more like sane-find-scanner is actually
> build with usb-support?

Yup.  And if I am not mistaken, that came from libusb-compat which you
subsequently nuked.  The error message is interesting though (in light
of those *.pc files you pasted).

  dyld: Library not loaded: /usr/local/opt/libusb-compat/lib/libusb-0.1.4.dylib

The libusb.pc mentions a version of 0.1.5_1 (emulated_by=libusb-1.0 ??)
and libusb-1.0.pc mentions 1.0.21.

Hmm, libusb is 0.1.5?  Seriously?  The latest version is 0.1.12 and that
was released years ago.  How does that jive with a 0.1.4.dylib?

# I'm not expecting you to answer this.  I am just thinking "out loud".

> So i reinstalled (build-from-source) sane-backends (after deactivating
> the dependency for libusb-compat) and it bombed (of course).
> Logs from that: https://gist.github.com/dfbe878620c1ae20f1bcbda44dbe37e3
> So i reinstalled libusb-compat and now i'm back to where i started.

Based on the above, I would drop the 10+ year old duct tape that goes by
the name of libusb-compat and look at fixing whatever thwarts pkg-config
finding one of those *.pc files, preferably libusb-1.0.pc.

Hmm, ...

Having another round through the info in the various links you and Yurii
provided I noticed

  checking for pkg-config... no

Is homebrew using pkgconfig instead?  If so, I'd suggest adding
something like

  system "ln", "-s", "pkg-config", "/usr/bin/pkgconfig"

*before* running configure to sane-backends.rb.  Adjust /usr/bin as
necessary.  While at it, also drop the

  depends_on "libusb-compat"

or replace it with something like

  depends_on "libusb-1.0"

at least, do yourself a favour and build against libusb-1.0.

So far for tonight's debugging session ;-)  If you still have trouble,
don't hesitate to "bother" me (and the list ;-)

Hope this helps,
Olaf Meeuwissen, LPIC-2            FSF Associate Member since 2004-01-27
 GnuPG key: F84A2DD9/B3C0 2F47 EA19 64F4 9F13  F43E B8A4 A88A F84A 2DD9
 Support Free Software                        https://my.fsf.org/donate
 Join the Free Software Foundation              https://my.fsf.org/join

More information about the sane-devel mailing list