且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

C ++如何管理依赖项(例如,使用来自github的库)

更新时间:2022-06-12 22:21:16

C ++没有类似pipnpm/bower的东西.我不知道能否说服mavengradle处理C ++库.

C++ doesn't have anything like pip or npm/bower. I don't know if maven or gradle can be persuaded to handle C++ libraries.

通常,您将不得不结束

  • 目录中的头文件
  • 库文件(静态库或DLL/共享对象).如果该库是像某些Boost库一样的仅标头库,那么您将不需要此库.

您可以通过在计算机上构建文件库(对于开放源代码项目和针对Linux平台的项目而言)来获取库文件,或者通过下载预编译的二进制文件(对于Windows库,尤其是付费库文件)来控制库文件).

You get hold of the library files, either by building them on your machine (typical for open source projects, and projects aimed at Linux platforms), or by downloading the pre-compiled binaries (typical for Windows libraries, particularly paid-for).

希望,有关图书馆建设的说明将包含在图书馆的网站上.正如评论中指出的那样,元"似乎在这方面相当出色.

Hopefully, the instructions for building the library will be included on the library website. As noted in the comments, 'meta' seems to be quite good at that.

当尝试使用该库进行编译时,可能需要命令行选项(例如-I)来指定包含头文件的目录,并且可能需要链接器选项(例如-l)来告诉该库.链接器链接到您的图书馆.

When you try to compile with the library, you may need a command line option (eg -I) to specify the directory containing the header files, and you may need a linker option (eg -l) to tell the linker to link against your library.