add libusb-win32 to vc project

windows下面使用libusb开源库

下载已经编译好的libusb libusb-win32-bin-1.2.6.0

目录结构:

libusb-win32-bin-1.2.6.0
├── AUTHORS.txt
├── bin
│   ├── amd64
│   ├── ia64
│   ├── inf-wizard.exe
│   ├── libusb-win32-bin-README.txt
│   └── x86
├── COPYING_GPL.txt
├── COPYING_LGPL.txt
├── examples
│   ├── benchmark.c
│   ├── BenchmarkHelp.txt
│   ├── benchmark_rc.rc
│   ├── bulk.c
│   ├── driver_installer_template.iss
│   └── testbulk_rc.rc
├── include
│   └── lusb0_usb.h
├── installer_license.txt
├── lib
│   ├── bcc
│   ├── dynamic
│   ├── gcc
│   ├── msvc
│   ├── msvc_i64
│   └── msvc_x64
├── libusb-win32-changelog-1.2.6.0.txt
└── README.txt

根据下面的步骤将库添加到vc工程中
参考: stackoverflow

Typically you need to do 5 things to include a library in your project:

1) Add #include statements necessary files with declarations/interfaces, e.g.:

#include "library.h"
2) Add an include directory for the compiler to look into

-> Configuration Properties/VC++ Directories/Include Directories (click and edit, add a new entry)

3) Add a library directory for *.lib files:

-> Configuration Properties/VC++ Directories/Library Directories (click and edit, add a new entry)

4) Link the lib's *.lib files

-> Configuration Properties/Linker/Input/Additional Dependencies (e.g.: library.lib;

5) Place *.dll files either:

-> in the directory you'll be opening your final executable from or into Windows/system32

编写测试代码:
参考 examples/bulk.c

#include "stdafx.h"
#include "lusb0_usb.h"

#define MY_VID 0x0421
#define MY_PID 0x03C5

////////////////////////////////////////////////////
usb_dev_handle *open_dev(void)
{
    struct usb_bus *bus;
    struct usb_device *dev;

    for (bus = usb_get_busses(); bus; bus = bus->next)
    {
        for (dev = bus->devices; dev; dev = dev->next)
        {
            if (dev->descriptor.idVendor == MY_VID
                && dev->descriptor.idProduct == MY_PID)
            {
                return usb_open(dev);
            }
        }
    }
    return NULL;
}

int _tmain(int argc, _TCHAR* argv[])
{
        usb_dev_handle *dev = NULL; 
        usb_init(); 
        usb_find_busses(); 
        usb_find_devices(); 

        if (!(dev = open_dev()))
        {
            printf("error opening device: \n%s\n", usb_strerror());
            return 0;
        }
        else
        {
            printf("success: device %04X:%04X opened\n", MY_VID, MY_PID);
        }
    return 0;
}