简体   繁体   English

我应该如何管理 C 或 C++ 开源项目中的依赖关系?

[英]How should I manage dependencies in C or C++ open source projects?

I've got a few open source applications.我有一些开源应用程序。 These depend on a few third party components, notably Crypto++ and Boost.这些依赖于一些第三方组件,尤其是 Crypto++ 和 Boost。 There are a couple of options to take:有几个选择:

  • Put third party code into version control, and include it with distributions of my code.将第三方代码放入版本控制中,并将其包含在我的代码分发中。 On one hand, this is the easiest for people to use because they can compile directly out of my source control repository.一方面,这是人们最容易使用的,因为他们可以直接从我的源代码控制存储库中编译出来。 On the other, they might be wasting bandwidth downloading source they already have, or end up having to fight with my library in order to remove the third party bits.另一方面,他们可能会浪费他们已经拥有的带宽下载源,或者最终不得不与我的库进行斗争以删除第三方位。 Furthermore, source control tools often have trouble dealing with massive libraries like Boost.此外,源代码控制工具通常难以处理像 Boost 这样的大型库。
  • Don't include third party code at all.根本不包含第三方代码。 This forces people to go out of their way to be able to use my library.这迫使人们不要使用 go 才能使用我的库。 On the other hand it means my source control repository and distributions will be small.另一方面,这意味着我的源代码控制存储库和发行版会很小。
  • Something I have not yet anticipated.我还没有预料到的东西。

What should I do?我应该怎么办?

Note : I'm not working in an environment where reliance on a dependency mapper like aptitude , apt-get , or yum are acceptable.注意:我不在一个可以接受依赖映射器(如aptitudeapt-getyum )的环境中工作。

Option 3: Don't include it in your code distribution but instead include a (link to a) download, which should match the most recent version you support.选项 3:不要将其包含在您的代码分发中,而是包含一个(指向 a 的)下载,它应该与您支持的最新版本相匹配。
Also, explicitly list your dependencies and the most recent versions you support.此外,明确列出您的依赖项和您支持的最新版本。

This allows users to do however they want.这允许用户为所欲为。 Want your code with dependencies?想要你的代码有依赖关系吗? Load both from one source.从一个来源加载两者。 Want only part of the dependencies because you have the others?只想要部分依赖项,因为您有其他依赖项? Load part of them.加载其中的一部分。 Want only your code?只需要您的代码吗? Load it seperately.单独加载。

Option 4: Offer 2 versions, one including the dependencies and the other without but combined with option 3 above.选项 4:提供 2 个版本,一个包含依赖项,另一个不包含但与上面的选项 3 结合。

I suggest Autoconf which was designed to abstract these worries away from you.我建议使用Autoconf ,它旨在让您摆脱这些担忧。

I doubt you can be expected to maintain build scripts for all of your dependencies across all platforms.我怀疑您是否可以为所有平台上的所有依赖项维护构建脚本。 Another problem with keeping 3rd party code in your svn is that now you also need to track down their dependencies and so on.在 svn 中保留第 3 方代码的另一个问题是,现在您还需要跟踪它们的依赖关系等等。

I think its a good idea to have dependencies in the SVN.我认为在 SVN 中有依赖项是个好主意。 That way developers can simply check-out and compile.这样开发人员就可以简单地签出和编译。 Also you avoid the problem with different incompatible versions of your dependencies.您还可以避免依赖项的不同不兼容版本的问题。

If you put the dependencies in a separate folder then developers can choose not to check-out your dependencies if they alrdy have them...如果您将依赖项放在单独的文件夹中,那么开发人员可以选择不签出您的依赖项(如果他们已经拥有它们)...

If you have a good package manager, than I would definitely not include dependencies in your repository.如果您有一个好的 package 管理器,那么我绝对不会在您的存储库中包含依赖项。 If you list the dependencies, it should be pretty easy for someone compiling it to get them from the repos.如果您列出依赖项,那么编译它以从存储库中获取它们应该很容易。

If you wanted to, you could include all of the dependencies as an additional download if you wanted to.如果您愿意,可以将所有依赖项作为附加下载包含在内。 But mixing them in with the code your working is generally not a good idea.但是将它们与您的工作代码混合通常不是一个好主意。

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

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