Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Handling of C++ Dependencies (Cross Platform)

I have the impression that this question was asked like a hundred times, but never fully answered.

I am working on a smallish project, that at some point should be released for the big three PC platforms (Windows, Mac & GNU/Linux), so locking yourself into technology to early is a bad idea. Luckily but also unfortunately, for now, during early development, we only target 32-bit Windows.

On a code level, cross platform development is relatively easy, if you pick the right libraries. Also building software on multiple platforms is relatively straight forward, I am looking into using either GYP or CMake.

The problem are the dependencies. To build the project you need: SDL, SDL_image, SDL_ttf, iconv, libxml2, libxmlmm, sigc++, wxWidgets, glew, bullet, openALsoft and maybe more added later.

So far I have found three options:

  1. check in sources and build them as part of the project
  2. check in binaries
  3. manage dependencies outside of the source tree

The first seems like overkill, since you need to basically maintain your fork of the library and your custom build system.

The second option sounds like the thing to do when your target only one or maybe two platforms. But if you count all different targets, including 32/64 bit variants, this also starts to balloon into something barely manageable.

The third option depends on the environment. If you let your developers handle the dependencies manually you will never sleep at nigh. Just getting each and every dependency built and ready to be used is barely impossible. Not to mention that you can't ensure that each developer uses the correct version.

If you look at other languages, they solve the problem differently. With systems like npm, marvin or phing, you only maintain some configuration file in the project and the tools then fetch any dependencies needed.

I was thinking about building the dependencies centrally, packaging them into zip/deb/rpm/whatever packages and putting them into a repository. Then each developer would copy the dependencies for his platform into the repository (but no check them in) before building. This would be done preferably automatically as a pre-build step.

I especially don't want an additional build system. I have looked around and the only thing that remotely does what I want may be Ivy. But either am missing something or Ivy is totally over engineering the problem. Does something simple exist to solve this problem?

I am inches of building my own.

like image 421
rioki Avatar asked May 02 '13 12:05

rioki


1 Answers

I would recommend against building your own.

We use ant/ivy/Hudson to automate our cross platform (Windows and Linux) builds. We also use Nexus (Maven) as our artifact repository which contains platform specific builds of our 3rd party libraries as well as our own application. Hudson integrates cleanly with Perforce (our software repository).

We are also in the process of creating separate 32-bit and 64-bit artifacts of everything and ant/ivy will make this significantly easier.

It has worked out great for us.

like image 128
rohitsan Avatar answered Oct 11 '22 15:10

rohitsan