简体   繁体   English

管理第三方库安装C ++

[英]Manage 3rd party libraries installation C++

I am wondering how to intelligently manage the building and installation for some of our 3rd party C++ dependencies on Linux(Ubuntu). 我想知道如何智能地管理我们在Linux(Ubuntu)上的一些第三方C ++依赖项的构建和安装。 The way I currently have it set up is a git-lfs with all the necessary compressed 3rd party sources. 我目前的设置方式是git-lfs,其中包含所有必需的压缩的第三方资源。 I then use a shell script I wrote to install all the necessary system dependencies and then unzip and build the desired library. 然后,我使用编写的Shell脚本安装所有必要的系统依赖项,然后解压缩并构建所需的库。 This shell script also takes care setting up all the paths so that our source code can easily link to the 3rd party libraries. 此Shell脚本还应注意设置所有路径,以便我们的源代码可以轻松链接到第三方库。

Example commands for our script are ./install opencv or ./install everything 我们脚本的示例命令是./install opencv或./install everything

However, over the months the script has gotten quite large and breaks sometimes when certain libraries are already installed or other minor issues. 但是,在过去的几个月中,脚本已经变得很大,有时会在某些库已安装或其他次要问题时中断。 Thus I would like to replace it with something a bit more intelligent and useful. 因此,我想用更智能,更有用的东西代替它。 I have currently been looking into writing some kind of python script, but just changing the language from shell to python is not that big of an advantage. 我目前一直在研究编写某种python脚本,但是将语言从shell更改为python并不是一个很大的优势。 So I am looking if there are any specific python libraries that can help me with managing these libraries. 所以我在寻找是否有任何特定的python库可以帮助我管理这些库。

I have looked into things like chef and other automated builds stuff, but that is overkill for the small project I am working on. 我已经研究过诸如Chef和其他自动构建的东西,但这对于我正在从事的小项目来说是过大了。

I was wondering what other people used for this 3rd party management stuff, as sadly C++ does not have anything like pip. 我想知道其他人在这第三方管理中使用了什么,可悲的是C ++没有pip之类的东西。

I use jhbuild for this kind of thing (if I understand what you are doing correctly). 我将jhbuild用于此类操作(如果我了解您的操作正确)。 It came out of the GNOME project (they use it to build the whole desktop from source), but it's easy to customize for any set of projects. 它来自GNOME项目(他们使用它从源代码构建整个桌面),但是很容易为任何项目集进行自定义。 The jhbuild packaged in recent Ubuntus works fine. 最近的jhbuild打包的jhbuild正常工作。

You write a little XML to describe each project: where to download the sources, what patches to apply, what configure flags to use, what projects it depends on, and so on; 您编写了一些XML来描述每个项目:在何处下载源代码,要应用哪些补丁,要使用哪些配置标志,它所依赖的项目等等。 then when you enter jhbuild build mything it works out what to build and in what order and gets on with it. 然后,当您输入jhbuild build mythingjhbuild build mything要构建的内容以及构建的顺序,然后继续进行下去。 It's reasonably smart about changes, so if you edit a source file in one of the projects that makes up your stack, it'll only rebuild the affected parts. 进行更改是相当明智的,因此,如果您在组成堆栈的项目之一中编辑源文件,则它只会重建受影响的部分。

For example, I have this for fftw3, the excellent fast Fourier transform library: 例如,对于fftw3(出色的快速傅立叶变换库),我有此功能:

  <autotools id="fftw3" 
    autogen-sh="configure"
    autogenargs="--disable-static --enable-shared --disable-threads"
    >
    <branch
      repo="fftw"
      module="fftw-3.3.4.tar.gz"
    />
    <dependencies>
      <dep package="libiconv"/>
    </dependencies>
  </autotools>

With probably obvious meanings. 具有可能明显的含义。 That's building from a release tarball, but it can build from git as well. 这是从发行版tarball构建的,但也可以从git构建。 It's happy with cmake projects. cmake项目很满意。 jhbuild is written in Python, so it's simple to customize. jhbuild是用Python编写的,因此自定义很简单。 Thanks to GNOME, many common libraries are included. 多亏了GNOME,其中包括许多常见的库。

I actually use it to build Windows binaries. 我实际上使用它来构建Windows二进制文件。 You can set it up to build everything with a cross-compiler, then put it inside Docker. 您可以将其设置为使用交叉编译器构建所有内容,然后将其放入Docker。 It makes it a one-liner for anyone to be able to build a large and complex application on (almost) any platform. 它使任何人都可以在(几乎)任何平台上构建大型而复杂的应用程序,这是一种统一的方式。 You can use it to do automated nightly builds as well, of course. 当然,您也可以使用它来进行自动夜间构建。

There are probably better things around, but it has worked well for me. 周围可能会有更好的事情,但是对我来说效果很好。

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

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