Click here to Skip to main content
14,976,190 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
I've been trying all day now to use libusb.lib within a visual studio 2008 project and cannot get it to work in any way.

I've created a clr console application, added libusb.lib to linker->input->additional dependencies. (The lib is in the correct directory too)

I have placed the usb.h header file into visual studios includes as well.

The moment Ii add a call to the library such as usb_init(), it complains about it being an unresolved link error!

Error   1   error LNK2028: unresolved token (0A000012) "extern "C" void __cdecl usb_init(void)" (?usb_init@@$$J0YAXXZ) referenced in function "int __clrcall main(cli::array<class System::String ^ >^)" (?main@@$$HYMHP$01AP$AAVString@System@@@Z) **** YOU WINDOWS.obj

I haven't used VC in quite some time now, so I am totally stumped.

It is C++ or C++/CLI part? From your error message one can see this is C++ with native (unmanaged) code. Perhaps you only need to remove C++/CLI link from your tags, even if you use it in your project.

Most likely, you're trying to use libusb-win32 which is not available or not added to your project. In this case, see:[^].

Are you sure the function is exported from that lib? There may be multiple libs. Or it may not be the right version of the lib.

Just to be sure it's not a C++/CLI issue, you can try adding the lib to a native project and then see if you get the same error.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900