将 libusb 链接到我的项目 [英] Linking libusb to my project

查看:32
本文介绍了将 libusb 链接到我的项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在弄清楚如何使用 libusb 时遇到问题,我输入了libusb-1.0.18-rc1\libusb"在包含目录中(使用 Visua Studio),但它不起作用.

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!

错误信息:

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

推荐答案

如果您还没有这样做,您将需要构建您将链接到的库,它们位于 \libusb-1.0.18-rc1\msvc.那里有多个项目,具体取决于您的 Visual Studio 版本以及您想要 DLL 还是静态 LIB 文件.

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.

无论哪种情况,您都需要右键单击您的项目,然后在 Configuration Properties -> Linker -> Input -> Additional Dependencies 下添加对您创建的 LIB 文件的引用.如果您链接到已完成的静态 LIB 文件,它会将代码构建到您的可执行文件中.如果您要链接到 DLL 的 LIB 文件,请确保该 DLL 在您的执行路径中可用.无论哪种情况,这都应该解决您未解决的外部问题.

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.

这篇关于将 libusb 链接到我的项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆