# Problem with libusb



## zeiz (Apr 7, 2009)

I'm trying to install KDE4.2.2 on CURRENT after updating kernel and world to yesterday's src.

```
===>   kdebase-workspace-4.2.2 depends on shared library: usb-0.1.8 - not found
===>    Verifying install for usb-0.1.8 in /usr/ports/devel/libusb
===>  libusb-0.1.12_4 has been already included into base system.
*** Error code 1
Stop in /usr/ports/devel/libusb.
*** Error code 1
```
make install in /devel/libusb gives the same message and libusb is not installed by any means. What does it mean "included" if it's in ports but it's not installable?
I read UPDATING dated 20090309 and although it's 1 month old I tried to follow but pkg_info output is "no match" that I understand as "no libusb-* in /db/pkg.
Does it mean that KDE4.2.2 is not currently installable on CURRENT or some workarounds exist?


----------



## SirDice (Apr 7, 2009)

> What does it mean "included" if it's in ports but it's not installable?


It means it's part of the base system on -current. The port is for 'older' versions of freebsd.


----------



## zeiz (Apr 7, 2009)

Did you mean that 8-CURRENT ports designed also for some 'older' version lets say 7-STABLE?


----------



## phoenix (Apr 8, 2009)

There is only 1 ports tree.  You use the same ports tree on FreeBSD 5.x, 6.x, 7.x, and 8.x.  Some ports have checks for specific versions in the Makefile and will only work on certain versions of FreeBSD.  Most of the time, port maintainers try to test their ports against as many versions of FreeBSD as possible, but they can't always test against everything.  And few have the resources to test against -CURRENT.

When the new USB stack (aka USB2) was imported into -CURRENT and replaced the old USB stack (aka USB1), it included a new version of libusb under /usr/lib.  A testing request was put out on the FreeBSD ports mailing list, to try and find ports that would need fixing due to this.

Looks like they missed one.  No biggie, you found the bug, so it should be fixable.

Submit a PR for that port, and/or send a message to the freebsd-ports@freebsd.org mailing list and to the port maintainer.  Then the port will get fixed to work on -CURRENT as well as on older versions.


----------



## Phillip (Mar 29, 2010)

Hello folks,

I am now building nut and encounter the same problem as zeiz, 

```
[root@sparta /build/nut]# make
===>  Vulnerability check disabled, database not found
===>  Extracting for nut-2.4.1
=> MD5 Checksum OK for nut-2.4.1.tar.gz.
=> SHA256 Checksum OK for nut-2.4.1.tar.gz.
=> MD5 Checksum OK for nut-2.4.1.tar.gz.sig.
=> SHA256 Checksum OK for nut-2.4.1.tar.gz.sig.
===>  Patching for nut-2.4.1
===>  Applying FreeBSD patches for nut-2.4.1
===>   nut-2.4.1 depends on executable: gmake - found
===>   nut-2.4.1 depends on file: /usr/local/bin/autoconf-2.62 - found
===>   nut-2.4.1 depends on executable: pkg-config - found
===>   nut-2.4.1 depends on shared library: usb-0.1.12_4 - not found
===>    Verifying install for usb-0.1.12_4 in /usr/ports/devel/libusb
===>  libusb-0.1.12_4 has been already included into base system.
*** Error code 1
```

While my OS is FreeBSD 8.0 which is downloaded from its official site at last week, I googled and find this patch, 
http://miwi.homeunix.com/patches/kdebase4-workspace.diff

```
+.if ${OSVERSION} < 800069
+LIB_DEPENDS+=	usb-0.1.8:${PORTSDIR}/devel/libusb
+.endif
+
```

It seems to be related to current version. and then I check my OS:


```
[root@sparta ~]# sysctl -n kern.osreldate
800107
```

From the result, I do not need "+LIB_DEPENDS+=	usb-0.1.8:${PORTSDIR}/devel/libusb". So I recommend this line in original Makefile and go on compile. It Is OK.

Hi Phoenix, 

It is not fixed in CURRENT BSD, Should reopen this "bug" again?

Thanks,

Phillip


----------



## phoenix (Mar 29, 2010)

The patch you posted adds three lines to the Makefile, making the libusb dependency dependent on the version of FreeBSD:  if the version is < 800069 then use libusb from ports, otherwise use libusb from base.

Update your ports tree to double-check that the fix is missing from the nut Makefile.  If it is, then either add a post to the existing PR saying it's not fixed, or submit a new one if this is a different port.


----------



## Phillip (Apr 1, 2010)

Update here,

1. Upgrade the port tree,
  # portsnap fetch extract
  # portsnap fetch update

2. Recommend line "LIB_DEPENDS+=usb-0.1.8:${PORTSDIR}/devel/libusb" and Enter the build/ports/nut directory, 

```
# make clean install
...
===>  Installing for nut-2.4.1
===>   nut-2.4.1 depends on executable: pkg-config - found
===>   Generating temporary packing list
===>  Checking if sysutils/nut already installed
install: /usr/local/freenas/svn/build/ports/nut/work/nut-2.4.1/data/cmdvartab -> /usr/local/freenas/rootfs//usr/local/etc/nut/cmdvartab
install: /usr/local/freenas/svn/build/ports/nut/work/nut-2.4.1/data/driver.list -> /usr/local/freenas/rootfs//usr/local/etc/nut/driver.list
install: /usr/local/freenas/svn/build/ports/nut/work/nut-2.4.1/drivers/apcsmart -> /usr/local/freenas/rootfs//usr/local/libexec/nut/apcsmart
install: /usr/local/freenas/svn/build/ports/nut/work/nut-2.4.1/drivers/bcmxcp -> /usr/local/freenas/rootfs//usr/local/libexec/nut/bcmxcp
install: /usr/local/freenas/svn/build/ports/nut/work/nut-2.4.1/drivers/bcmxcp_usb: No such file or directory
```

It seems that bcmxcp_usb can not be found. I modify the makefile and set "--with-usb=yes" and try to make again.


```
#make clean install
...
checking whether to build serial drivers... yes
checking whether to build SNMP drivers... no
configure: error: "USB drivers requested, but libusb not found."
===>  Script "configure" failed unexpectedly.
Please report the problem to votdev@gmx.de [maintainer] and attach the
"/usr/local/freenas/svn/build/ports/nut/work/nut-2.4.1/config.log" including
the output of the failure of your make command. Also, it might be a good idea
to provide an overview of all packages installed on your system (e.g. an `ls
/var/db/pkg`).
*** Error code 1

Stop in /usr/local/freenas/svn/build/ports/nut.
*** Error code 1

Stop in /usr/local/freenas/svn/build/ports/nut.
```

By google the error message, I find this page "http://www.root0.net/problem/index.html" which told me to install libusb or its devel package. It takes a about 20minutes to find the libusb-0.1.12_4.tbz.(You can download it from: http://ftp2.za.freebsd.org/pub/FreeBSD/ports/i386/packages-7-stable/devel/), Install the package and later nut.


```
# pkg_add libusb-0.1.12_4.tbz 
# pkg_info | grep libusb
libusb-0.1.12_4     Library giving userland programs access to USB devices

# make clean install
...
===>   Running ldconfig
/sbin/ldconfig -m /usr/local/lib
===>   Registering installation for nut-2.4.1
```

Nut is built successfully! 

Summary.
1. Check your BSD version. If it is higher enough(as my 800170), I suggest you recommend the following two lines in its included file.
    In /usr/ports/devel/libusb/Makefile

```
#.if ${OSVERSION} >= 800069
       #IGNORE=         has been already included into base system
      # .endif
```
    In build/port/nut/Makefile

```
#LIB_DEPENDS+=          usb-0.1.8:${PORTSDIR}/devel/libusb
     --with-usb=yes  (change the default "auto" to "yes")
```

2. Check libusb package has been installed.
   # pkg_info | grep libusb

3. Build nut.

Hope this helpful for some guys(like me, a BSD newbie) future reference, 


Phillip


----------

