Question

I am having problem figure out how to use libusb, I put "libusb-1.0.18-rc1\libusb" in include directories (using Visua Studio), but it doesn't work.

Can anyone enlighten me. Thanks a lot!

error message:

1>test.obj : error LNK2019: unresolved external symbol _libusb_exit@4 referenced in   function _main
1>test.obj : error LNK2019: unresolved external symbol _libusb_close@4 referenced in function _main
1>test.obj : error LNK2019: unresolved external symbol _libusb_release_interface@8 referenced in function _main
1>test.obj : error LNK2019: unresolved external symbol _libusb_bulk_transfer@24 referenced in function _main
1>test.obj : error LNK2019: unresolved external symbol _libusb_claim_interface@8 referenced in function _main
1>test.obj : error LNK2019: unresolved external symbol _libusb_detach_kernel_driver@8 referenced in function _main
1>test.obj : error LNK2019: unresolved external symbol _libusb_kernel_driver_active@8 referenced in function _main
1>test.obj : error LNK2019: unresolved external symbol _libusb_free_device_list@8 referenced in function _main
1>test.obj : error LNK2019: unresolved external symbol _libusb_open_device_with_vid_pid@12 referenced in function _main
1>test.obj : error LNK2019: unresolved external symbol _libusb_get_device_list@8 referenced in function _main
1>test.obj : error LNK2019: unresolved external symbol _libusb_set_debug@8 referenced in function _main
1>test.obj : error LNK2019: unresolved external symbol _libusb_init@4 referenced in function _main
Was it helpful?

Solution

If you havne't done so already you will need to build the libraries you will be linking to, they are located in \libusb-1.0.18-rc1\msvc. There are multiple projects there depending on your Visual Studio version and whether you want a DLL or a static LIB file.

In either case you will need to right click on your project, then under Configuration Properties -> Linker -> Input -> Additional Dependencies add a reference to the LIB file you created. If you are linking to the static LIB file you're done, it will build the code in to your executable. If you're linking to the LIB file for the DLL make sure the DLL is available in your execution path. In either case this should resolve your unresolved externals.

OTHER TIPS

I think you must take the 32-Bit Version of the libusb-Library/DLL and ensure 32 Bit Compile at Project Properies. That solved my Problem with LNK2019.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top