Problem including libusb doesn't recognize the functions or variables of libusb



  • I am tried to compile a file with the header a his source file, both of them have the line to include the libusb library on GNU/Linux OS with this line

    #include <libusb-1.0/libusb.h>
    

    cyusb.c

    /*******************************************************************************\
     * Program Name		:	libcyusb.c					*
     * Author		:	V. Radhakrishnan ( rk@atr-labs.com )		*
     * License		:	GPL Ver 2.0					*
     * Copyright		:	Cypress Semiconductors Inc. / ATR-LABS		*
     * Date written		:	March 12, 2012					*
     * Modification Notes	:							*
     * 										*
     * This program is the main library for all cyusb applications to use.		*
     * This is a thin wrapper around libusb						*
    \*******************************************************************************/
    
    #include <stdio.h>
    #include <unistd.h>
    #include <stdlib.h>
    #include <string.h>
    #include <errno.h>
    #include <fcntl.h>
    
    #include <libusb-1.0/libusb.h>
    #include "cyusb.h"
    
    /* Maximum length of a string read from the Configuration file (/etc/cyusb.conf) for the library. */
    #define MAX_CFG_LINE_LENGTH                     (120)
    
    static struct cydev cydev[MAXDEVICES];
    static int nid;		/* Number of Interesting Devices	*/
    
    struct VPD {
        unsigned short	vid;
        unsigned short	pid;
        char		desc[MAX_STR_LEN];
    };
    
    static struct VPD vpd[MAX_ID_PAIRS];
    
    static int maxdevices;
    static int numdev;
    static libusb_device **list;
    static unsigned int checksum = 0;
    
    char pidfile[256];
    char logfile[256];
    int logfd;
    int pidfd;
    
    static int isempty(char *buf, int L)
    {
        int flag = 1;
        int i;
    
        if ( L == 0 ) return 1;
    
        for (i = 0; i < L; ++i ) {
            if ( (buf[i] == ' ') || ( buf[i] == '\t' ) )
             continue;
            else {
             flag = 0;
             break;
            }
        }
        return flag;
    }
    
    static void parse_configfile(void)
    {
        FILE *inp;
        char buf[MAX_CFG_LINE_LENGTH];
        char *cp1, *cp2, *cp3;
        int i;
    
        inp = fopen("/etc/cyusb.conf", "r");
            if (inp == NULL)
                return;
    
        memset(buf,'\0',MAX_CFG_LINE_LENGTH);
        while ( fgets(buf,MAX_CFG_LINE_LENGTH,inp) ) {
            if ( buf[0] == '#' ) 			/* Any line starting with a # is a comment 	*/
               continue;
            if ( buf[0] == '\n' )
               continue;
            if ( isempty(buf,strlen(buf)) )		/* Any blank line is also ignored		*/
               continue;
    
            cp1 = strtok(buf," =\t\n");
            if ( !strcmp(cp1,"LogFile") ) {
               cp2 = strtok(NULL," \t\n");
               strcpy(logfile,cp2);
            }
            else if ( !strcmp(cp1,"PIDFile") ) {
                cp2 = strtok(NULL," \t\n");
                strcpy(pidfile,cp2);
            }
            else if ( !strcmp(cp1,"<VPD>") ) {
                while ( fgets(buf,MAX_CFG_LINE_LENGTH,inp) ) {
                    if ( buf[0] == '#' ) 		/* Any line starting with a # is a comment 	*/
                       continue;
                    if ( buf[0] == '\n' )
                       continue;
                    if ( isempty(buf,strlen(buf)) )	/* Any blank line is also ignored		*/
                       continue;
                    if ( maxdevices == (MAX_ID_PAIRS - 1) )
                       continue;
                    cp1 = strtok(buf," \t\n");
                    if ( !strcmp(cp1,"</VPD>") )
                       break;
                    cp2 = strtok(NULL, " \t");
                    cp3 = strtok(NULL, " \t\n");
    
                    vpd[maxdevices].vid = strtol(cp1,NULL,16);
                    vpd[maxdevices].pid = strtol(cp2,NULL,16);
                    strncpy(vpd[maxdevices].desc,cp3,MAX_STR_LEN);
                                    vpd[maxdevices].desc[MAX_STR_LEN - 1] = '\0';   /* Make sure of NULL-termination. */
    
                    ++maxdevices;
                }
            }
            else {
                 printf("Error in config file /etc/cyusb.conf: %s \n",buf);
                 exit(1);
            }
        }
    
        fclose(inp);
    }
    
    static int device_is_of_interest(cyusb_device *d)
    {
        int i;
        int found = 0;
        struct libusb_device_descriptor desc;
        int vid;
        int pid;
    
        libusb_get_device_descriptor(d, &desc);
        vid = desc.idProduct;
        pid = desc.idProduct;
    
        for ( i = 0; i < maxdevices; ++i ) {
            if ( (vpd[i].vid == desc.idVendor) && (vpd[i].pid == desc.idProduct) ) {
                found = 1;
            break;
            }
        }
        return found;
    }
    
    unsigned short cyusb_getvendor(cyusb_handle *h)
    {
        struct libusb_device_descriptor d;
        cyusb_get_device_descriptor(h, &d);
        return d.idVendor;
    }
    
    unsigned short cyusb_getproduct(cyusb_handle *h)
    {
        struct libusb_device_descriptor d;
        cyusb_get_device_descriptor(h, &d);
        return d.idProduct;
    }
    
    static int renumerate(void)
    {
        cyusb_device *dev = NULL;
        cyusb_handle *handle = NULL;
        int found = 0;
        int i;
        int r;
    
        numdev = libusb_get_device_list(NULL, &list);
        if ( numdev < 0 ) {
           printf("Library: Error in enumerating devices...\n");
           return -4;
        }
    
        nid = 0;
    
        for ( i = 0; i < numdev; ++i ) {
            cyusb_device *tdev = list[i];
            if ( device_is_of_interest(tdev) ) {
               cydev[nid].dev = tdev;
               r = libusb_open(tdev, &cydev[nid].handle);
               if ( r ) {
                  printf("Error in opening device\n");
                  return -5;
               }
               else handle = cydev[nid].handle;
               cydev[nid].vid     = cyusb_getvendor(handle);
               cydev[nid].pid     = cyusb_getproduct(handle);
               cydev[nid].is_open = 1;
               cydev[nid].busnum  = cyusb_get_busnumber(handle);
               cydev[nid].devaddr = cyusb_get_devaddr(handle);
               ++nid;
            }
        }
        return nid;
    }
    
    int cyusb_open(unsigned short vid, unsigned short pid)
    {
        int r;
        cyusb_handle *h = NULL;
    
        r = libusb_init(NULL);
        if (r) {
              printf("Error in initializing libusb library...\n");
              return -1;
        }
        h = libusb_open_device_with_vid_pid(NULL, vid, pid);
        if ( !h ) {
           printf("Device not found\n");
           return -2;
        }
        cydev[0].dev     = libusb_get_device(h);
        cydev[0].handle  = h;
        cydev[nid].vid     = cyusb_getvendor(h);
        cydev[nid].pid     = cyusb_getproduct(h);
        cydev[nid].is_open = 1;
        cydev[nid].busnum  = cyusb_get_busnumber(h);
        cydev[nid].devaddr = cyusb_get_devaddr(h);
        nid = 1;
        return 1;
    }
    
    void cyusb_error(int err)
    {	if ( err == -1 )
           fprintf(stderr, "Input/output error\n");
        else if ( err == -2 )
            fprintf(stderr, "Invalid parameter\n");
        else if ( err == -3 )
            fprintf(stderr, "Access denied (insufficient permissions)\n");
        else if ( err == -4 )
            fprintf(stderr, "No such device. Disconnected...?\n");
        else if ( err == -5 )
            fprintf(stderr, "Entity not found\n");
        else if ( err == -6 )
            fprintf(stderr, "Resource busy\n");
        else if ( err == -7 )
            fprintf(stderr, "Operation timed out\n");
        else if ( err == -8 )
            fprintf(stderr, "Overflow\n");
        else if ( err == -9 )
            fprintf(stderr, "Pipe error\n");
        else if ( err == -10 )
            fprintf(stderr, "System call interrupted, ( due to signal ? )\n");
        else if ( err == -11 )
            fprintf(stderr, "Insufficient memory\n");
        else if ( err == 12 )
            fprintf(stderr, "Operation not supported/implemented\n");
        else fprintf(stderr, "Unknown internal error\n");
    }
    
    
    cyusb_handle * cyusb_gethandle(int index)
    {
        return cydev[index].handle;
    }
    
    void cyusb_close(void)
    {
        int i;
    
        for ( i = 0; i < nid; ++i ) {
            libusb_close(cydev[i].handle);
        }
        libusb_free_device_list(list, 1);
        libusb_exit(NULL);
    }
    
    int cyusb_get_busnumber(cyusb_handle *h)
    {
        cyusb_device *tdev = libusb_get_device(h);
        return libusb_get_bus_number( tdev );
    }
    
    int cyusb_get_devaddr(cyusb_handle *h)
    {
        cyusb_device *tdev = libusb_get_device(h);
        return libusb_get_device_address( tdev );
    }
    
    int cyusb_get_max_packet_size(cyusb_handle *h, unsigned char endpoint)
    {
        cyusb_device *tdev = libusb_get_device(h);
        return ( libusb_get_max_packet_size(tdev, endpoint) );
    }
    
    int cyusb_get_max_iso_packet_size(cyusb_handle *h, unsigned char endpoint)
    {
        cyusb_device *tdev = libusb_get_device(h);
        return ( libusb_get_max_iso_packet_size(tdev, endpoint) );
    }
    
    int cyusb_get_configuration(cyusb_handle *h, int *config)
    {
        return ( libusb_get_configuration(h, config) );
    }
    
    int cyusb_set_configuration(cyusb_handle *h, int config)
    {
        return ( libusb_set_configuration(h, config) );
    }
    
    int cyusb_claim_interface(cyusb_handle *h, int interface)
    {
        return ( libusb_claim_interface(h, interface) );
    }
    
    int cyusb_release_interface(cyusb_handle *h, int interface)
    {
        return ( libusb_release_interface(h, interface) );
    }
    
    int cyusb_set_interface_alt_setting(cyusb_handle *h, int interface, int altsetting)
    {
        return ( libusb_set_interface_alt_setting(h, interface, altsetting) );
    }
    
    int cyusb_clear_halt(cyusb_handle *h, unsigned char endpoint)
    {
        return ( libusb_clear_halt(h, endpoint) );
    }
    
    int cyusb_reset_device(cyusb_handle *h)
    {
        return ( libusb_reset_device(h) );
    }
    
    int cyusb_kernel_driver_active(cyusb_handle *h, int interface)
    {
        return ( libusb_kernel_driver_active(h, interface) );
    }
    
    int cyusb_detach_kernel_driver(cyusb_handle *h, int interface)
    {
        return ( libusb_detach_kernel_driver(h, interface) );
    }
    
    int cyusb_attach_kernel_driver(cyusb_handle *h, int interface)
    {
        return ( libusb_attach_kernel_driver(h, interface) );
    }
    
    int cyusb_get_device_descriptor(cyusb_handle *h, struct libusb_device_descriptor *desc)
    {
        cyusb_device *tdev = libusb_get_device(h);
        return ( libusb_get_device_descriptor(tdev, desc ) );
    }
    
    int cyusb_get_active_config_descriptor(cyusb_handle *h, struct libusb_config_descriptor **config)
    {
        cyusb_device *tdev = libusb_get_device(h);
        return ( libusb_get_active_config_descriptor(tdev, config) );
    }
    
    int cyusb_get_config_descriptor(cyusb_handle *h, unsigned char config_index, struct libusb_config_descriptor **config)
    {
        cyusb_device *tdev = libusb_get_device(h);
        return ( libusb_get_config_descriptor(tdev, config_index, config) );
    }
    
    int cyusb_get_config_descriptor_by_value(cyusb_handle *h, unsigned char bConfigurationValue,
                                        struct usb_config_descriptor **config)
    {
        cyusb_device *tdev = libusb_get_device(h);
        return ( libusb_get_config_descriptor_by_value(tdev, bConfigurationValue,
                        (struct libusb_config_descriptor **)config) );
    }
    
    void cyusb_free_config_descriptor(struct libusb_config_descriptor *config)
    {
        libusb_free_config_descriptor( (libusb_config_descriptor *)config );
    }
    
    int cyusb_get_string_descriptor_ascii(cyusb_handle *h, unsigned char index, unsigned char *data,  int length)
    {
        cyusb_device *tdev = libusb_get_device(h);
        return ( libusb_get_string_descriptor_ascii(h, index, data, length) );
    }
    
    int cyusb_get_descriptor(cyusb_handle *h, unsigned char desc_type, unsigned char desc_index, unsigned char *data,
            int len)
    {
        return ( libusb_get_descriptor(h, desc_type, desc_index, data, len) );
    }
    
    int cyusb_get_string_descriptor(cyusb_handle *h, unsigned char desc_index, unsigned short langid,
                                    unsigned char *data, int len)
    {
        return ( libusb_get_string_descriptor(h, desc_index, langid, data, len) );
    }
    
    int cyusb_control_transfer(cyusb_handle *h, unsigned char bmRequestType, unsigned char bRequest,
            unsigned short wValue, unsigned short wIndex, unsigned char *data, unsigned short wLength,
            unsigned int timeout)
    {
        return ( libusb_control_transfer(h, bmRequestType, bRequest, wValue, wIndex, data, wLength, timeout) );
    }
    
    int cyusb_control_read (cyusb_handle *h, unsigned char bmRequestType, unsigned char bRequest,
            unsigned short wValue, unsigned short wIndex, unsigned char *data, unsigned short wLength,
            unsigned int timeout)
    {
        /* Set the direction bit to indicate a read transfer. */
        return ( libusb_control_transfer(h, bmRequestType | 0x80, bRequest, wValue, wIndex, data, wLength, timeout) );
    }
    
    int cyusb_control_write (cyusb_handle *h, unsigned char bmRequestType, unsigned char bRequest,
            unsigned short wValue, unsigned short wIndex, unsigned char *data, unsigned short wLength,
            unsigned int timeout)
    {
        /* Clear the direction bit to indicate a write transfer. */
        return ( libusb_control_transfer(h, bmRequestType & 0x7F, bRequest, wValue, wIndex, data, wLength, timeout) );
    }
    
    int cyusb_bulk_transfer(cyusb_handle *h, unsigned char endpoint, unsigned char *data, int length,
                    int *transferred, int timeout)
    {
        return ( libusb_bulk_transfer(h, endpoint, data, length, transferred, timeout) );
    }
    
    int cyusb_interrupt_transfer(cyusb_handle *h, unsigned char endpoint, unsigned char *data, int length,
                    int *transferred, unsigned int timeout)
    {
        return ( libusb_interrupt_transfer(h, endpoint, data, length, transferred, timeout) );
    }
    
    
    static void control_transfer(cyusb_handle *h, unsigned int address, unsigned char *dbuf, int len)
    {
        int j;
        int r;
        int b;
        unsigned int *pint;
        int index;
    
        int balance = len;
        pint = (unsigned int *)dbuf;
    
        index = 0;
        while ( balance > 0 ) {
              if ( balance > 4096 )
             b = 4096;
              else b = balance;
              r = cyusb_control_transfer(h, 0x40, 0xA0, ( address & 0x0000ffff ), address >> 16, &dbuf[index], b, 1000);
              if ( r != b ) {
               printf("Error in control_transfer\n");
              }
              address += b ;
              balance -= b;
              index += b;
        }
        for ( j = 0; j < len/4; ++j )
            checksum += pint[j];
    }
    

    I am getting this error

    /home/pasante/Escritorio/simple-player/src/cyusb.c:372: error: ‘libusb_config_descriptor’ undeclared (first use in this function)
    libusb_free_config_descriptor( (libusb_config_descriptor *)config );
    ^~~~~~~~~~~~~~~~~~~~~~~~
    libusb_config_descriptor is not declared

    if i eliminate the function where that variable appears, any variable or function of libusb are recognized


  • Qt Champions 2016

    Hi
    Can you show your .pro file ?

    Its unclear how you LINK to the actual lib.

    http://doc.qt.io/qtcreator/creator-project-qmake-libraries.html



  • Looks like this question is nothing to do with Qt. But still where is the structure libusb_config_descriptor defined ? This structure may not be available in your library. Please check it.



  • @mrjj said in Problem including libusb doesn't recognize the functions or variables of libusb:

    Hi
    Can you show your .pro file ?

    Its unclear how you LINK to the actual lib.

    http://doc.qt.io/qtcreator/creator-project-qmake-libraries.html

    .pro

    #
    # VLC-Qt Simple Player
    # Copyright (C) 2015 Tadej Novak <tadej@tano.si>
    #
    
    TARGET      = simple-player
    TEMPLATE    = app
    CONFIG 	   += c++11
    
    QT         += widgets
    
    SOURCES    += main.cpp \
        SimplePlayer.cpp \
        EqualizerDialog.cpp \
        connection.cpp \
        cyusb.c
    
    HEADERS    += SimplePlayer.h \
        EqualizerDialog.h \
        connection.h \
        cyusb.h
    
    FORMS      += SimplePlayer.ui \
        EqualizerDialog.ui
    
    LIBS       += -lVLCQtCore -lVLCQtWidgets 
    
    
    # Edit below for custom library location
    LIBS       += -L/Users/tadej/workspace/tanoprojects/install/vlc-qt/lib -lVLCQtCore -lVLCQtWidgets 
    INCLUDEPATH += /Users/tadej/workspace/tanoprojects/install/vlc-qt/include 
    
    RESOURCES += \
        icons.qrc
    

    I am doing some search about added the path to the .pro file, here it's where libusb are located in my computer, but i am not sure how to added to the .pro i was only able to find the header here /usr/include/libusb-1.0/libusb.h and not the lib

    pasante@pasante-MN-50:~$ locate libusb
    /lib/firmware/carl9170fw/extra/libusb-zeropacket.diff
    /lib/x86_64-linux-gnu/libusb-1.0.so.0
    /lib/x86_64-linux-gnu/libusb-1.0.so.0.1.0
    /opt/Qt5.8.0/5.8/Src/coin/provisioning/qtci-linux-RHEL-6.6-x86_64/libusb.sh
    /opt/Qt5.8.0/5.8/Src/coin/provisioning/qtci-linux-Ubuntu-14.04-x86_64/libusb.sh
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/build/linux/unbundle/libusb.gyp
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/BUILD.gn
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/OWNERS
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/README.chromium
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/assign-endpoints-checks.patch
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/composite-hid-close.patch
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/darwin-sigfpe.patch
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/libusb.gyp
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/linux-udev.patch
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/open-fd.patch
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/upstream-tick147.patch
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/windows-build.patch
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/AUTHORS
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/COPYING
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/config.h
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/libusb
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/msvc
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/libusb/core.c
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/libusb/descriptor.c
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/libusb/hotplug.c
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/libusb/hotplug.h
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/libusb/interrupt.c
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/libusb/interrupt.h
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/libusb/io.c
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/libusb/libusb.h
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/libusb/libusbi.h
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/libusb/os
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/libusb/strerror.c
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/libusb/sync.c
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/libusb/version.h
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/libusb/version_nano.h
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/libusb/os/DEPS
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/libusb/os/darwin_usb.c
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/libusb/os/darwin_usb.h
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/libusb/os/linux_netlink.c
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/libusb/os/linux_udev.cc
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/libusb/os/linux_usbfs.c
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/libusb/os/linux_usbfs.h
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/libusb/os/openbsd_usb.c
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/libusb/os/poll_posix.c
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/libusb/os/poll_posix.h
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/libusb/os/poll_windows.c
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/libusb/os/poll_windows.h
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/libusb/os/threads_posix.c
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/libusb/os/threads_posix.h
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/libusb/os/threads_windows.c
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/libusb/os/threads_windows.h
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/libusb/os/wince_usb.c
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/libusb/os/wince_usb.h
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/libusb/os/windows_common.h
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/libusb/os/windows_usb.c
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/libusb/os/windows_usb.h
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/msvc/config.h
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/msvc/errno.h
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/msvc/inttypes.h
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/msvc/missing.c
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/msvc/missing.h
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/msvc/stdint.h
    /opt/Qt5.8.0/Docs/Qt-5.8/qtwebengine/qtwebengine-3rdparty-libusbx.html
    /usr/include/libusb-1.0
    /usr/include/libusb-1.0/libusb.h
    /usr/lib/x86_64-linux-gnu/libusb-1.0.a
    /usr/lib/x86_64-linux-gnu/libusb-1.0.so
    /usr/lib/x86_64-linux-gnu/libusbmuxd.so.4
    /usr/lib/x86_64-linux-gnu/libusbmuxd.so.4.0.0
    /usr/lib/x86_64-linux-gnu/pkgconfig/libusb-1.0.pc
    /usr/share/doc/libusb-1.0-0
    /usr/share/doc/libusb-1.0-0-dbg
    /usr/share/doc/libusb-1.0-0-dev
    /usr/share/doc/libusb-1.0-doc
    /usr/share/doc/libusbmuxd4
    /usr/share/doc/libusb-1.0-0/README
    /usr/share/doc/libusb-1.0-0/changelog.Debian.gz
    /usr/share/doc/libusb-1.0-0/copyright
    /usr/share/doc/libusb-1.0-0-dbg/changelog.Debian.gz
    /usr/share/doc/libusb-1.0-0-dbg/copyright
    /usr/share/doc/libusb-1.0-0-dev/README
    /usr/share/doc/libusb-1.0-0-dev/changelog.Debian.gz
    /usr/share/doc/libusb-1.0-0-dev/copyright
    /usr/share/doc/libusb-1.0-doc/PORTING
    /usr/share/doc/libusb-1.0-doc/README
    /usr/share/doc/libusb-1.0-doc/changelog.Debian.gz
    /usr/share/doc/libusb-1.0-doc/copyright
    /usr/share/doc/libusb-1.0-doc/html
    /usr/share/doc/libusb-1.0-doc/html/annotated.html
    /usr/share/doc/libusb-1.0-doc/html/api.html
    /usr/share/doc/libusb-1.0-doc/html/arrowdown.png
    /usr/share/doc/libusb-1.0-doc/html/arrowright.png
    /usr/share/doc/libusb-1.0-doc/html/bc_s.png
    /usr/share/doc/libusb-1.0-doc/html/bdwn.png
    /usr/share/doc/libusb-1.0-doc/html/caveats.html
    /usr/share/doc/libusb-1.0-doc/html/classes.html
    /usr/share/doc/libusb-1.0-doc/html/closed.png
    /usr/share/doc/libusb-1.0-doc/html/contexts.html
    /usr/share/doc/libusb-1.0-doc/html/dir_6560186179ae86ab3fbed805e7cb86e4.html
    /usr/share/doc/libusb-1.0-doc/html/doc.png
    /usr/share/doc/libusb-1.0-doc/html/doxygen.css
    /usr/share/doc/libusb-1.0-doc/html/doxygen.png
    /usr/share/doc/libusb-1.0-doc/html/files.html
    /usr/share/doc/libusb-1.0-doc/html/folderclosed.png
    /usr/share/doc/libusb-1.0-doc/html/folderopen.png
    /usr/share/doc/libusb-1.0-doc/html/functions.html
    /usr/share/doc/libusb-1.0-doc/html/functions_vars.html
    /usr/share/doc/libusb-1.0-doc/html/group__asyncio.html
    /usr/share/doc/libusb-1.0-doc/html/group__desc.html
    /usr/share/doc/libusb-1.0-doc/html/group__dev.html
    /usr/share/doc/libusb-1.0-doc/html/group__hotplug.html
    /usr/share/doc/libusb-1.0-doc/html/group__lib.html
    /usr/share/doc/libusb-1.0-doc/html/group__misc.html
    /usr/share/doc/libusb-1.0-doc/html/group__poll.html
    /usr/share/doc/libusb-1.0-doc/html/group__syncio.html
    /usr/share/doc/libusb-1.0-doc/html/hotplug.html
    /usr/share/doc/libusb-1.0-doc/html/index.html
    /usr/share/doc/libusb-1.0-doc/html/io.html
    /usr/share/doc/libusb-1.0-doc/html/jquery.js
    /usr/share/doc/libusb-1.0-doc/html/libusb_8h_source.html
    /usr/share/doc/libusb-1.0-doc/html/modules.html
    /usr/share/doc/libusb-1.0-doc/html/mtasync.html
    /usr/share/doc/libusb-1.0-doc/html/nav_f.png
    /usr/share/doc/libusb-1.0-doc/html/nav_g.png
    /usr/share/doc/libusb-1.0-doc/html/nav_h.png
    /usr/share/doc/libusb-1.0-doc/html/open.png
    /usr/share/doc/libusb-1.0-doc/html/packetoverflow.html
    /usr/share/doc/libusb-1.0-doc/html/pages.html
    /usr/share/doc/libusb-1.0-doc/html/splitbar.png
    /usr/share/doc/libusb-1.0-doc/html/structlibusb__bos__descriptor.html
    /usr/share/doc/libusb-1.0-doc/html/structlibusb__bos__dev__capability__descriptor.html
    /usr/share/doc/libusb-1.0-doc/html/structlibusb__config__descriptor.html
    /usr/share/doc/libusb-1.0-doc/html/structlibusb__container__id__descriptor.html
    /usr/share/doc/libusb-1.0-doc/html/structlibusb__control__setup.html
    /usr/share/doc/libusb-1.0-doc/html/structlibusb__device__descriptor.html
    /usr/share/doc/libusb-1.0-doc/html/structlibusb__endpoint__descriptor.html
    /usr/share/doc/libusb-1.0-doc/html/structlibusb__interface.html
    /usr/share/doc/libusb-1.0-doc/html/structlibusb__interface__descriptor.html
    /usr/share/doc/libusb-1.0-doc/html/structlibusb__iso__packet__descriptor.html
    /usr/share/doc/libusb-1.0-doc/html/structlibusb__pollfd.html
    /usr/share/doc/libusb-1.0-doc/html/structlibusb__ss__endpoint__companion__descriptor.html
    /usr/share/doc/libusb-1.0-doc/html/structlibusb__ss__usb__device__capability__descriptor.html
    /usr/share/doc/libusb-1.0-doc/html/structlibusb__transfer.html
    /usr/share/doc/libusb-1.0-doc/html/structlibusb__usb__2__0__extension__descriptor.html
    /usr/share/doc/libusb-1.0-doc/html/structlibusb__version.html
    /usr/share/doc/libusb-1.0-doc/html/sync_off.png
    /usr/share/doc/libusb-1.0-doc/html/sync_on.png
    /usr/share/doc/libusb-1.0-doc/html/tab_a.png
    /usr/share/doc/libusb-1.0-doc/html/tab_b.png
    /usr/share/doc/libusb-1.0-doc/html/tab_h.png
    /usr/share/doc/libusb-1.0-doc/html/tab_s.png
    /usr/share/doc/libusb-1.0-doc/html/tabs.css
    /usr/share/doc/libusb-1.0-doc/html/version_8h_source.html
    /usr/share/doc/libusb-1.0-doc/html/version__nano_8h_source.html
    /usr/share/doc/libusbmuxd4/changelog.Debian.gz
    /usr/share/doc/libusbmuxd4/copyright
    /usr/share/doc-base/libusb-1.0-doc
    /usr/share/lintian/overrides/libusbmuxd4
    /var/cache/apt/archives/libusb-1.0-0-dbg_2%3a1.0.20-1_amd64.deb
    /var/cache/apt/archives/libusb-1.0-0-dev_2%3a1.0.20-1_amd64.deb
    /var/cache/apt/archives/libusb-1.0-doc_2%3a1.0.20-1_all.deb
    /var/lib/dpkg/info/libusb-1.0-0-dbg:amd64.list
    /var/lib/dpkg/info/libusb-1.0-0-dbg:amd64.md5sums
    /var/lib/dpkg/info/libusb-1.0-0-dev:amd64.list
    /var/lib/dpkg/info/libusb-1.0-0-dev:amd64.md5sums
    /var/lib/dpkg/info/libusb-1.0-0:amd64.list
    /var/lib/dpkg/info/libusb-1.0-0:amd64.md5sums
    /var/lib/dpkg/info/libusb-1.0-0:amd64.shlibs
    /var/lib/dpkg/info/libusb-1.0-0:amd64.symbols
    /var/lib/dpkg/info/libusb-1.0-0:amd64.triggers
    /var/lib/dpkg/info/libusb-1.0-doc.list
    /var/lib/dpkg/info/libusb-1.0-doc.md5sums
    /var/lib/dpkg/info/libusbmuxd4:amd64.list
    /var/lib/dpkg/info/libusbmuxd4:amd64.md5sums
    /var/lib/dpkg/info/libusbmuxd4:amd64.shlibs
    /var/lib/dpkg/info/libusbmuxd4:amd64.symbols
    /var/lib/dpkg/info/libusbmuxd4:amd64.triggers
    
    

    Can help my to fill this

    LIBS += -L[LOCATION_OF_THE_libusb_LIBRARY_ON_THE_SYSTEM]
    INCLUDEPATH += [LOCATION_OF_libusb_HEADER_FILE]
    DEPENDPATH += [LOCATION_OF_libusb_HEADER_FILE]
    PRE_TARGETDEPS += [LOCATION_OF_libusb.a_ARCHIVE_FILE_OF_THE_LIBRARY]

    I couldn't find the lib any clue?

    this is what i have

    LIBS += -L
    INCLUDEPATH += /usr/include/libusb-1.0/
    DEPENDPATH += /usr/include/libusb-1.0/libusb.h
    PRE_TARGETDEPS += /usr/lib/x86_64-linux-gnu/



  • /lib/x86_64-linux-gnu/libusb-1.0.so.0 is present under the directory /lib/x86_64-linux-gnu/

    LIBS += -L/lib/x86_64-linux-gnu -llibusb
    INCLUDE PATH +=/usr/include/libusb-1.0/


  • Qt Champions 2016

    Did you do
    sudo apt-get install libusb-1.0-0-dev

    or was it already installed ?
    mine is in
    /lib/i386-linux-gnu/libusb-1.0.so.0
    (Mint 64)



  • I am making easy this way a simple program to display the information from USB.

    I made the .pro getting information from the command in console locate libusb

    pasante@pasante-MN-50:~$ locate libusb
    /lib/firmware/carl9170fw/extra/libusb-zeropacket.diff
    /lib/x86_64-linux-gnu/libusb-1.0.so.0
    /lib/x86_64-linux-gnu/libusb-1.0.so.0.1.0
    /opt/Qt5.8.0/5.8/Src/coin/provisioning/qtci-linux-RHEL-6.6-x86_64/libusb.sh
    /opt/Qt5.8.0/5.8/Src/coin/provisioning/qtci-linux-Ubuntu-14.04-x86_64/libusb.sh
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/build/linux/unbundle/libusb.gyp
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/BUILD.gn
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/OWNERS
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/README.chromium
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/assign-endpoints-checks.patch
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/composite-hid-close.patch
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/darwin-sigfpe.patch
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/libusb.gyp
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/linux-udev.patch
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/open-fd.patch
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/upstream-tick147.patch
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/windows-build.patch
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/AUTHORS
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/COPYING
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/config.h
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/libusb
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/msvc
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/libusb/core.c
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/libusb/descriptor.c
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/libusb/hotplug.c
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/libusb/hotplug.h
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/libusb/interrupt.c
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/libusb/interrupt.h
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/libusb/io.c
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/libusb/libusb.h
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/libusb/libusbi.h
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/libusb/os
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/libusb/strerror.c
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/libusb/sync.c
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/libusb/version.h
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/libusb/version_nano.h
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/libusb/os/DEPS
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/libusb/os/darwin_usb.c
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/libusb/os/darwin_usb.h
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/libusb/os/linux_netlink.c
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/libusb/os/linux_udev.cc
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/libusb/os/linux_usbfs.c
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/libusb/os/linux_usbfs.h
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/libusb/os/openbsd_usb.c
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/libusb/os/poll_posix.c
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/libusb/os/poll_posix.h
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/libusb/os/poll_windows.c
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/libusb/os/poll_windows.h
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/libusb/os/threads_posix.c
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/libusb/os/threads_posix.h
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/libusb/os/threads_windows.c
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/libusb/os/threads_windows.h
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/libusb/os/wince_usb.c
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/libusb/os/wince_usb.h
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/libusb/os/windows_common.h
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/libusb/os/windows_usb.c
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/libusb/os/windows_usb.h
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/msvc/config.h
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/msvc/errno.h
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/msvc/inttypes.h
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/msvc/missing.c
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/msvc/missing.h
    /opt/Qt5.8.0/5.8/Src/qtwebengine/src/3rdparty/chromium/third_party/libusb/src/msvc/stdint.h
    /opt/Qt5.8.0/Docs/Qt-5.8/qtwebengine/qtwebengine-3rdparty-libusbx.html
    /usr/include/libusb-1.0
    /usr/include/libusb-1.0/libusb.h
    /usr/lib/x86_64-linux-gnu/libusb-1.0.a
    /usr/lib/x86_64-linux-gnu/libusb-1.0.so
    /usr/lib/x86_64-linux-gnu/libusbmuxd.so.4
    /usr/lib/x86_64-linux-gnu/libusbmuxd.so.4.0.0
    /usr/lib/x86_64-linux-gnu/pkgconfig/libusb-1.0.pc
    /usr/share/doc/libusb-1.0-0
    /usr/share/doc/libusb-1.0-0-dbg
    /usr/share/doc/libusb-1.0-0-dev
    /usr/share/doc/libusb-1.0-doc
    /usr/share/doc/libusbmuxd4
    /usr/share/doc/libusb-1.0-0/README
    /usr/share/doc/libusb-1.0-0/changelog.Debian.gz
    /usr/share/doc/libusb-1.0-0/copyright
    /usr/share/doc/libusb-1.0-0-dbg/changelog.Debian.gz
    /usr/share/doc/libusb-1.0-0-dbg/copyright
    /usr/share/doc/libusb-1.0-0-dev/README
    /usr/share/doc/libusb-1.0-0-dev/changelog.Debian.gz
    /usr/share/doc/libusb-1.0-0-dev/copyright
    /usr/share/doc/libusb-1.0-doc/PORTING
    /usr/share/doc/libusb-1.0-doc/README
    /usr/share/doc/libusb-1.0-doc/changelog.Debian.gz
    /usr/share/doc/libusb-1.0-doc/copyright
    /usr/share/doc/libusb-1.0-doc/html
    /usr/share/doc/libusb-1.0-doc/html/annotated.html
    /usr/share/doc/libusb-1.0-doc/html/api.html
    /usr/share/doc/libusb-1.0-doc/html/arrowdown.png
    /usr/share/doc/libusb-1.0-doc/html/arrowright.png
    /usr/share/doc/libusb-1.0-doc/html/bc_s.png
    /usr/share/doc/libusb-1.0-doc/html/bdwn.png
    /usr/share/doc/libusb-1.0-doc/html/caveats.html
    /usr/share/doc/libusb-1.0-doc/html/classes.html
    /usr/share/doc/libusb-1.0-doc/html/closed.png
    /usr/share/doc/libusb-1.0-doc/html/contexts.html
    /usr/share/doc/libusb-1.0-doc/html/dir_6560186179ae86ab3fbed805e7cb86e4.html
    /usr/share/doc/libusb-1.0-doc/html/doc.png
    /usr/share/doc/libusb-1.0-doc/html/doxygen.css
    /usr/share/doc/libusb-1.0-doc/html/doxygen.png
    /usr/share/doc/libusb-1.0-doc/html/files.html
    /usr/share/doc/libusb-1.0-doc/html/folderclosed.png
    /usr/share/doc/libusb-1.0-doc/html/folderopen.png
    /usr/share/doc/libusb-1.0-doc/html/functions.html
    /usr/share/doc/libusb-1.0-doc/html/functions_vars.html
    /usr/share/doc/libusb-1.0-doc/html/group__asyncio.html
    /usr/share/doc/libusb-1.0-doc/html/group__desc.html
    /usr/share/doc/libusb-1.0-doc/html/group__dev.html
    /usr/share/doc/libusb-1.0-doc/html/group__hotplug.html
    /usr/share/doc/libusb-1.0-doc/html/group__lib.html
    /usr/share/doc/libusb-1.0-doc/html/group__misc.html
    /usr/share/doc/libusb-1.0-doc/html/group__poll.html
    /usr/share/doc/libusb-1.0-doc/html/group__syncio.html
    /usr/share/doc/libusb-1.0-doc/html/hotplug.html
    /usr/share/doc/libusb-1.0-doc/html/index.html
    /usr/share/doc/libusb-1.0-doc/html/io.html
    /usr/share/doc/libusb-1.0-doc/html/jquery.js
    /usr/share/doc/libusb-1.0-doc/html/libusb_8h_source.html
    /usr/share/doc/libusb-1.0-doc/html/modules.html
    /usr/share/doc/libusb-1.0-doc/html/mtasync.html
    /usr/share/doc/libusb-1.0-doc/html/nav_f.png
    /usr/share/doc/libusb-1.0-doc/html/nav_g.png
    /usr/share/doc/libusb-1.0-doc/html/nav_h.png
    /usr/share/doc/libusb-1.0-doc/html/open.png
    /usr/share/doc/libusb-1.0-doc/html/packetoverflow.html
    /usr/share/doc/libusb-1.0-doc/html/pages.html
    /usr/share/doc/libusb-1.0-doc/html/splitbar.png
    /usr/share/doc/libusb-1.0-doc/html/structlibusb__bos__descriptor.html
    /usr/share/doc/libusb-1.0-doc/html/structlibusb__bos__dev__capability__descriptor.html
    /usr/share/doc/libusb-1.0-doc/html/structlibusb__config__descriptor.html
    /usr/share/doc/libusb-1.0-doc/html/structlibusb__container__id__descriptor.html
    /usr/share/doc/libusb-1.0-doc/html/structlibusb__control__setup.html
    /usr/share/doc/libusb-1.0-doc/html/structlibusb__device__descriptor.html
    /usr/share/doc/libusb-1.0-doc/html/structlibusb__endpoint__descriptor.html
    /usr/share/doc/libusb-1.0-doc/html/structlibusb__interface.html
    /usr/share/doc/libusb-1.0-doc/html/structlibusb__interface__descriptor.html
    /usr/share/doc/libusb-1.0-doc/html/structlibusb__iso__packet__descriptor.html
    /usr/share/doc/libusb-1.0-doc/html/structlibusb__pollfd.html
    /usr/share/doc/libusb-1.0-doc/html/structlibusb__ss__endpoint__companion__descriptor.html
    /usr/share/doc/libusb-1.0-doc/html/structlibusb__ss__usb__device__capability__descriptor.html
    /usr/share/doc/libusb-1.0-doc/html/structlibusb__transfer.html
    /usr/share/doc/libusb-1.0-doc/html/structlibusb__usb__2__0__extension__descriptor.html
    /usr/share/doc/libusb-1.0-doc/html/structlibusb__version.html
    /usr/share/doc/libusb-1.0-doc/html/sync_off.png
    /usr/share/doc/libusb-1.0-doc/html/sync_on.png
    /usr/share/doc/libusb-1.0-doc/html/tab_a.png
    /usr/share/doc/libusb-1.0-doc/html/tab_b.png
    /usr/share/doc/libusb-1.0-doc/html/tab_h.png
    /usr/share/doc/libusb-1.0-doc/html/tab_s.png
    /usr/share/doc/libusb-1.0-doc/html/tabs.css
    /usr/share/doc/libusb-1.0-doc/html/version_8h_source.html
    /usr/share/doc/libusb-1.0-doc/html/version__nano_8h_source.html
    /usr/share/doc/libusbmuxd4/changelog.Debian.gz
    /usr/share/doc/libusbmuxd4/copyright
    /usr/share/doc-base/libusb-1.0-doc
    /usr/share/lintian/overrides/libusbmuxd4
    /var/cache/apt/archives/libusb-1.0-0-dbg_2%3a1.0.20-1_amd64.deb
    /var/cache/apt/archives/libusb-1.0-0-dev_2%3a1.0.20-1_amd64.deb
    /var/cache/apt/archives/libusb-1.0-doc_2%3a1.0.20-1_all.deb
    /var/lib/dpkg/info/libusb-1.0-0-dbg:amd64.list
    /var/lib/dpkg/info/libusb-1.0-0-dbg:amd64.md5sums
    /var/lib/dpkg/info/libusb-1.0-0-dev:amd64.list
    /var/lib/dpkg/info/libusb-1.0-0-dev:amd64.md5sums
    /var/lib/dpkg/info/libusb-1.0-0:amd64.list
    /var/lib/dpkg/info/libusb-1.0-0:amd64.md5sums
    /var/lib/dpkg/info/libusb-1.0-0:amd64.shlibs
    /var/lib/dpkg/info/libusb-1.0-0:amd64.symbols
    /var/lib/dpkg/info/libusb-1.0-0:amd64.triggers
    /var/lib/dpkg/info/libusb-1.0-doc.list
    /var/lib/dpkg/info/libusb-1.0-doc.md5sums
    /var/lib/dpkg/info/libusbmuxd4:amd64.list
    /var/lib/dpkg/info/libusbmuxd4:amd64.md5sums
    /var/lib/dpkg/info/libusbmuxd4:amd64.shlibs
    /var/lib/dpkg/info/libusbmuxd4:amd64.symbols
    /var/lib/dpkg/info/libusbmuxd4:amd64.triggers
    
    

    the .pro file look like this

    #-------------------------------------------------
    #
    # Project created by QtCreator 2017-01-31T11:51:20
    #
    #-------------------------------------------------
    
    QT       += core gui
    
    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
    
    TARGET = usb_test
    TEMPLATE = app
    
    # The following define makes your compiler emit warnings if you use
    # any feature of Qt which as been marked as deprecated (the exact warnings
    # depend on your compiler). Please consult the documentation of the
    # deprecated API in order to know how to port your code away from it.
    DEFINES += QT_DEPRECATED_WARNINGS
    
    # You can also make your code fail to compile if you use deprecated APIs.
    # In order to do so, uncomment the following line.
    # You can also select to disable deprecated APIs only up to a certain version of Qt.
    #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
    
    
    SOURCES += main.cpp\
            mainwindow.cpp
    
    HEADERS  += mainwindow.h
    
    FORMS    += mainwindow.ui
    
    LIBS += -L/usr/lib/x86_64-linux-gnu/
    INCLUDEPATH += /usr/include/libusb-1.0/
    DEPENDPATH += /usr/include/libusb-1.0/
    PRE_TARGETDEPS += /usr/lib/x86_64-linux-gnu/
    

    The mainwindows cpp is just a button who launch then function of the library libusb to get the devices, the tried to put it in a listwidget, i haven't move element to the listwidget because only in the function to get devices it doesn't compile

    #include "mainwindow.h"
    #include "ui_mainwindow.h"
    #include <QStringListModel>
    #include <QStringList>
    #include <QString>
    #include <libusb-1.0/libusb.h>
    
    MainWindow::MainWindow(QWidget *parent) :
        QMainWindow(parent),
        ui(new Ui::MainWindow)
    {
        ui->setupUi(this);
    
    }
    
    MainWindow::~MainWindow()
    {
        delete ui;
    }
    
    void MainWindow::on_pushButton_clicked()
    {
        libusb_device **list=NULL; //pointer to the pointer of the devices
        libusb_context *ctx=NULL;  //the context
    
        int notification = libusb_get_device_list(ctx,&list); //get a list of device fill dev[] struct
        
        QString casa="hello";
        ui->listWidget->addItem(casa);
    }
    

    when compile i get the error
    /home/pasante/Escritorio/build-usb_test-Desktop_Qt_5_8_0_GCC_64bit-Debug/mainwindow.o:-1: error:In function MainWindow::on_pushButton_clicked()': /home/pasante/Escritorio/usb_test/mainwindow.cpp:29: reference tolibusb_get_device_list' without define

    Its the same problem in the program before, this one i more simple, i don't know why is not deference the function of libusb



  • I found the solution, in the .pro you only need this to link libusb

    LIBS +=  -lusb-1.0
    

    Here a simple program with tow list widgets one for look the id product an other for the vendor in a decimal way

    #include "mainwindow.h"
    #include "ui_mainwindow.h"
    #include <QStringListModel>
    #include <QStringList>
    #include <QString>
    #include <libusb-1.0/libusb.h>
    #include <iostream>
    
    MainWindow::MainWindow(QWidget *parent) :
        QMainWindow(parent),
        ui(new Ui::MainWindow)
    {
        ui->setupUi(this);
    
    }
    
    MainWindow::~MainWindow()
    {
        delete ui;
    }
    
    void MainWindow::on_pushButton_clicked()
    {
        libusb_device **list=NULL; //pointer to the pointer od the device
        libusb_context *ctx=NULL;  //the context
    
        int r; //for return values
        ssize_t number_of_devices; //holding number of devices in list
        r = libusb_init(&ctx); //initialize a library session
        if(r < 0)
        {
            QString one_error="Error library inicialization";
            ui->listWidget->addItem(one_error);
    
        }
    
        libusb_set_debug(ctx, 3); //set verbosity level to 3, as suggested in the documentation
    
        number_of_devices = libusb_get_device_list(ctx,&list); //get a list of device fil dev[] struct
    
        if(number_of_devices < 0)
        {
            QString two_error="Any device found";
            ui->listWidget->addItem(two_error);
        }
    
        unsigned int i=0;  //Iteration the number of drivers founded
    
        libusb_device_descriptor descriptor; //Store the decriptions of the USB devices there were founded
    
        for (i=0;i<number_of_devices;i++)
        {
            int status = libusb_get_device_descriptor(list[i],&descriptor);
    
            if(status < 0)
            {
                QString three_error="Error on getting description";
                ui->listWidget->addItem(three_error);
            }
    
            QString idProduct= QString::number((int)descriptor.idProduct);
            QString idVendor= QString::number((int)descriptor.idVendor);
    
            ui->listWidget->addItem(idProduct);
            ui->listWidget_2->addItem(idVendor);
        }
    
    }
    
    

    You will ablel to see the different usb devices of your computer. I hope some one will find this and solve his problems with libusb qt and linux. It's necessary documentation about this point for other users, i lost a lot of time in this.

    Cheers guys, any more doubts i will write it in the forum.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.