简体   繁体   English

使用第三方库(libusb),如何安装和使用?

[英]Using third-party libraries (libusb), how to install and use?

I have never had to use libraries other than ones that I have created, and even then I have simply copied the source files into the same directory as the remainder of the project. 我从来没有使用过我创建的库以外的库,即便如此,我只是将源文件复制到与项目其余部分相同的目录中。 What are the steps to install and use libusb ? 安装和使用libusb有哪些步骤? I know that it is required to indicate to your respective IDE the pathway to the library, but to what exactly? 我知道需要向各自的IDE指出通往图书馆的途径,但具体到底是什么? To the folder containing the source? 到包含源的文件夹? Is it necessary to precompile the libraries first? 是否有必要首先预编译库?

I am not sure what to download from that link to get this going. 我不知道从该链接下载什么来实现这一目标。 There are options to sync via a repository to have the most up-to-date source, but is that necessary? 有一些选项可以通过存储库同步以获得最新的源,但这是必要的吗? I downloaded the tarball and have the source, but am not sure where to go from here. 我下载了tarball并有源代码,但我不知道从哪里开始。

Your compiler needs to know the path to the headers ( .h ), to find them when you #include and know which symbols (functions, structs ..) are available. 您的编译器需要知道标头的路径( .h ),以便在#include时找到它们并知道哪些符号(函数,结构......)可用。 Your linker needs to know the path to the corresponding compiled libraries ( .o / .a / .so ) containing the implementation. 链接器需要知道包含实现的相应编译库( .o / .a / .so )的路径。 You don't need the source code (C/C++ implementation code, "private" headers) to use a library. 您不需要源代码(C / C ++实现代码,“私有”标头)来使用库。

What you download depends on how you want to install it. 您下载的内容取决于您希望如何安装它。 If you are using a Linux distribution that already packages it, you can just install it using your package manager. 如果您使用已经打包它的Linux发行版,则可以使用包管理器安装它。 You can get the newest version of libusb throught GitHub too, it is only "necessary" if you want something that is in the newest version. 您也可以通过GitHub获取最新版本的libusb,如果您想要最新版本的东西,它只是“必要的”。 You can compile and install it in your /home or system wide. 您可以在/ home或系统范围内编译和安装它。 You can keep the sources in a separate directory next to your project's sources ( git submodule can help to manage that), and compile them at the same time as your project. 您可以将源保存在项目源旁边的单独目录中( git子模块可以帮助管理它),并在项目的同时编译它们。 How you install them is your choice, then you just need to configure your IDE/build system accordingly. 如何安装它们是您的选择,然后您只需相应地配置IDE /构建系统。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM