C ++如何管理依赖项(例如,使用来自github的库) [英] C++ how to manage dependencies (use libraries from github for example)

查看:114
本文介绍了C ++如何管理依赖项(例如,使用来自github的库)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对C ++世界还很陌生,所以请您为这个虚假的问题感到抱歉.我在Google上搜索了一下,但找不到正确的答案.

I'm very new to C++ world, so please, sorry me for such a dummy question. I google a little, but wasn't able to find proper answer.

我的问题很简单-我应该如何在C ++世界中使用lib.例如,在Java中-此任务有mavengradle.在Python中-我使用pip.用javascript npmbower进行所有操作.在C#中,您使用nuget或仅将DLL lib添加到您的项目中.但是看起来在C ++中,事情并不是那么容易.

My question is fairly simple - how should I use lib's in C++ world. For example in Java - there is maven and gradle for this task. In Python - I use pip. In javascript npm and bower do all the stuff. In C# you use nuget or just adding DLL lib to your project. But looks like in C++ things isn't such easy.

我找到了一个名为 conan 的工具,但是它们拥有的库数量很少,并且不包含任何库我想要的是什么.

I found a tool, called conan but ammount of libs they have is pretty small and don't include any what i'm loking for.

例如,我想使用nlp lib meta .似乎他们没有提供任何安装程序文件.所以我想我需要从github获取资源.我应该编译它们,然后尝试将已编译的文件添加到我的项目中,还是需要在我的项目中有lib文件夹,并将meta's源文件放在这些文件夹中,并在按meta's源文件对其进行操作之后再使用它们?

So, for example - I want to use nlp lib meta. Seem's like they don't provide any installer file. So I assume I need to get sources from github. Should I compile them and then trying to add compiled files to my project or I need to have lib folder in my project, and put meta's sources in those folder and after operate with meta's sources as they are in my project?

我的问题不是关于如何安装特定的meta lib,而是从源代码管理的角度出发.例如,如果我在Windows上使用Visual Studio,但是我的同事将在Linux下对Clion进行编码.而且我不会意识到哪种方法是在C ++世界中管理依赖项的正确方法.

My question isn't about how to install specific meta lib, but more from the source management point of view. If I use Visual Studio on Windows for example, but my colegue will be coding Clion under Linux. And I wan't to realize which is a proper way to managing dependencies in C++ world.

推荐答案

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.

这篇关于C ++如何管理依赖项(例如,使用来自github的库)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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