OpenWrt Forum Archive

Topic: libusb.h not found when trying to compile hplip

The content of this topic has been archived on 18 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

I'm starting to get nuts at this problem:
I'm trying to build hplip-3.13.5 on trunk, because in the prebuild 3.9.x my printer isn't supported.

So far, so good, but when I try to compile hplip I receive the following error:

In file included from io/hpmud/hpmudi.h:49:0,
                 from io/mudext/hpmudext.c:29:
io/hpmud/musb.h:33:20: fatal error: libusb.h: No such file or directory
compilation terminated.

What's kind of weird, because in the configure phase of the very same build it reads:

checking for libusb_init in -lusb-1.0... yes
checking libusb-1.0/libusb.h usability... yes
checking libusb-1.0/libusb.h presence... yes
checking for libusb-1.0/libusb.h... yes

I'm starting to drive mad, so any help is highly appreciated.

Have a look at the makefile I'm using:

#
# Copyright (C) 2006-2011 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#

include $(TOPDIR)/rules.mk

PKG_NAME:=hplip
PKG_VERSION:=3.13.5
#PKG_VERSION:=3.10.6
PKG_RELEASE:=4

PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=@SF/hplip
PKG_MD5SUM:= 
# cd7edef6b2df2cdb468b145cd2127e1b    # 3.13.2

PKG_BUILD_DEPENDS := python
PKG_FIXUP:=autoreconf

include $(INCLUDE_DIR)/package.mk

define Package/hplip
  SECTION:=utils
  CATEGORY:=Utilities
  TITLE:=HP Linux Imaging and Printing
  URL:=http://sourceforge.net/projects/hplip/
  DEPENDS+=+libjpeg +libtiff +libusb-1.0 +cups +sane-libs
endef

define Package/hplip/description
    HPLIP is an HP developed solution for printing, scanning, and faxing with HP inkjet and laser based printers in Linux.
endef

CONFIGURE_ARGS += \
    --disable-gui-build \
    --disable-network-build \
    --disable-fax-build \
    --disable-pp-build \
    --disable-doc-build \
    --enable-libusb \
    --disable-foomatic-xml-install \
    --disable-dbus-build

define Build/Configure
    $(call Build/Configure/Default,\
        $(CONFIGURE_ARGS),\
        ac_cv_lib_cups_cupsDoFileRequest=yes \
        LIBS="-lz -ljpeg -lusb-1.0 -lcups -lpng -ltiff" \
    )
endef

define Package/hplip/install
    $(INSTALL_DIR) $(1)/usr/lib
    $(CP) $(PKG_BUILD_DIR)/.libs/libhpip.so* $(1)/usr/lib/
    $(CP) $(PKG_BUILD_DIR)/.libs/libhpmud.so* $(1)/usr/lib/

    $(INSTALL_DIR) $(1)/usr/lib/cups/backend
    $(INSTALL_BIN) $(PKG_BUILD_DIR)/.libs/hp $(1)/usr/lib/cups/backend

    $(INSTALL_DIR) $(1)/usr/lib/sane
    $(CP) $(PKG_BUILD_DIR)/.libs/libsane-hpaio.so* $(1)/usr/lib/sane

    $(INSTALL_DIR) $(1)/etc/hp
    $(CP) $(PKG_BUILD_DIR)/hplip.conf $(1)/etc/hp/hplip.conf

    $(INSTALL_DIR) $(1)/usr/share/hplip/data/models/
    $(CP) $(PKG_BUILD_DIR)/data/models/models.dat $(1)/usr/share/hplip/data/models/

    $(INSTALL_DIR) $(1)/etc/hotplug.d/usb/
    $(INSTALL_BIN) ./files/20-hplip $(1)/etc/hotplug.d/usb/

    $(INSTALL_DIR) $(1)/etc/sane.d/dll.d/
    $(INSTALL_DATA) ./files/hplib.conf $(1)/etc/sane.d/dll.d/hplib
endef

define Package/hplip/conffiles
/etc/hp/hplip.conf
endef

$(eval $(call BuildPackage,hplip))

AFAICT, the libusb.h is part of package/libs/libusb package.

Actually, it's part of libusb-1.0, but hat doesn't solve the issue, as it's there, in the right place and even gets detected by configure of the build process in question - see above.

I'm desperate.

According to the error message you posted above (io/hpmud/musb.h:33:20: fatal error: libusb.h: No such file or directory), can you at least post the line #33 of the io/hpmud/musb.h file?

#include <libush.h>
dasMopo wrote:
#include <libush.h>

As I suspected. Do a search for libusb.h under your <OpenWRT root directory>/staging_dir and it will probably be installed under <OpenWRT root directory>/staging_dir/target-<platform>/usr/include/libusb-1.0/libusb.h. If so, then you will need to add a CFLAG=-I$(STAGING_DIR)/usr/include/libusb-1.0 to the OpenWRT Makefile for the hplip package.

I'm actually trying right that (found a corresponding reference to that extra cflag on another site), but have some other minor issues right now - I'll hopefully report back supplying a patch.

Thanks for the help !

As promised, here's the makefile that finally did the trick:

#
# Copyright (C) 2006-2011 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#

include $(TOPDIR)/rules.mk

PKG_NAME:=hplip
PKG_VERSION:=3.13.5
#PKG_VERSION:=3.10.6
PKG_RELEASE:=1

PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=@SF/hplip
PKG_MD5SUM:= 2b0906b4a57b437988829557ca62adfd
# cd7edef6b2df2cdb468b145cd2127e1b    # 3.13.2

PKG_BUILD_DEPENDS := python
PKG_FIXUP:=autoreconf
PKG_INSTALL:=1

include $(INCLUDE_DIR)/package.mk

define Package/hplip
  SECTION:=utils
  CATEGORY:=Utilities
  TITLE:=HP Linux Imaging and Printing
  URL:=http://sourceforge.net/projects/hplip/
  DEPENDS+=+libjpeg +libtiff +libusb-compat +cups +sane-libs +dbus +python +libcupsimage
endef

define Package/hplip/description
    HPLIP is an HP developed solution for printing, scanning, and faxing with HP inkjet and laser based printers in Linux.
endef

CONFIGURE_ARGS += \
    --disable-gui-build \
    --disable-network-build \
    --disable-fax-build \
    --disable-pp-build \
    --disable-doc-build \
    --enable-libusb \
    --disable-foomatic-xml-install \
    --disable-dbus-build
    --with-cupsbackenddir=/opt/lib/cups/backend \
    --with-cupsfilterdir=/opt/lib/cups/filter \
    --with-icondir=/opt/var \
    --with-systraydir=/opt/var
    
TARGET_CFLAGS += \
    -I$(STAGING_DIR)/usr/include/libusb-1.0

define Build/Configure
    $(call Build/Configure/Default,\
        $(CONFIGURE_ARGS),\
        ac_cv_lib_cups_cupsDoFileRequest=yes \
        LIBS="-lz -ljpeg -lusb-1.0 -lcups -lpng -ltiff" \
    )
endef

define Package/hplip/install
    $(INSTALL_DIR) $(1)/usr/lib
    $(CP) $(PKG_BUILD_DIR)/.libs/libhpip.so* $(1)/usr/lib/
    $(CP) $(PKG_BUILD_DIR)/.libs/libhpmud.so* $(1)/usr/lib/

    $(INSTALL_DIR) $(1)/usr/lib/cups/backend
    $(INSTALL_BIN) $(PKG_BUILD_DIR)/.libs/hp $(1)/usr/lib/cups/backend

    $(INSTALL_DIR) $(1)/usr/lib/sane
    $(CP) $(PKG_BUILD_DIR)/.libs/libsane-hpaio.so* $(1)/usr/lib/sane

    $(INSTALL_DIR) $(1)/etc/hp
    $(CP) $(PKG_BUILD_DIR)/hplip.conf $(1)/etc/hp/hplip.conf

    $(INSTALL_DIR) $(1)/usr/share/hplip/data/models/
    $(CP) $(PKG_BUILD_DIR)/data/models/models.dat $(1)/usr/share/hplip/data/models/

    $(INSTALL_DIR) $(1)/etc/hotplug.d/usb/
    $(INSTALL_BIN) ./files/20-hplip $(1)/etc/hotplug.d/usb/

    $(INSTALL_DIR) $(1)/etc/sane.d/dll.d/
    $(INSTALL_DATA) ./files/hplib.conf $(1)/etc/sane.d/dll.d/hplib
endef

define Package/hplip/conffiles
/etc/hp/hplip.conf
endef

$(eval $(call BuildPackage,hplip))

or u can just

#apt-get install libusb-1.0

The discussion might have continued from here.