18

C++ Buildsystem with ability to compile dependencies beforehand

Java has Maven which is a pleasure to work with, simply specifying dependencies that are already compiled, and deposited to Mavens standard directory, meaning that the location of the dependencies is standardized as opposed to the often used way of having multiple locations (give me a break, like anyone remembers the default installed directories for particular deps) of C/C++ dependencies.

It is massively unproductive for every individual developer having to, more often than not, find, read about, get familiar with the configure options/build, and finally compile for every dependency to simply make a build of a project.

What is the theoretical reason this has not been implemented?

Why would it be difficult to provide packages of the following options with a maven-like declaration format?

version
platform (windows, linux)
src/dev/bin
shared/static
equivalent set of Boost ABI options when applicable

Having to manually go to websites and search out dependencies in the year 2013 for the oldest major programming language is absurd.

6
  • 2
    I think your question is really just " is there an equivalent to Maven for C++?"... Jan 10, 2013 at 17:11
  • 5
    I think it's more "Obviously this thing should exist. It doesn't exist. Therefore there must be a good reason it doesn't exist. What is that reason?" Jan 10, 2013 at 17:16
  • 1
    Maybe because there are so many C++ ABIs, whereas Java (I think) essentially specifies one specific ABI? And the Debian system does something like this, though only for Linux.
    – aschepler
    Jan 10, 2013 at 17:24
  • 1
    I think the short answer is: there is no theoretical reason. It's simply something that (for whatever reason) nobody's done. Jan 10, 2013 at 17:29
  • 1
    @villapx Yes - "apt-get source [package]" will download a package's source to the current directory; and "apt-get build-dep [package]" will install the necessary tools, libraries, headers, etc. which are needed to build the package from source via "dpkg-buildpackage".
    – aschepler
    Mar 7, 2019 at 23:42

3 Answers 3

21

There aren't any theoretical reasons. There are a great many practical reasons. There are just too many different ways of handling things in the C++ world to easily standardize on a dependency system:

  • Implementation differences - C++ is a complicated language, and different implementations have historically varied in how well they support it (how well they can correctly handle various moderate to advanced C++ code). So there's no guarantee that a library could be built in a particular implementation.
  • Platform differences - Some platforms may not support exceptions. There are different implementations of the standard library, with various pros and cons. Unlike Java's standardized library, Windows and POSIX APIs can be quite different. The filesystem isn't even a part of Standard C++.
  • Compilation differences - Static or shared? Debug or production build? Enable optional dependencies or not? Unlike Java, which has very stable bytecode, C++'s lack of a standard ABI means that code may not link properly, even if built for the same platform by the same compiler.
  • Build system differences - Makefiles? (If so, GNU Make, or something else?) Autotools? CMake? Visual Studio project files? Something else?
  • Historical concerns - Because of C's and C++'s age, popular libraries like zlib predate build systems like Maven by quite a bit. Why should zlib switch to some hypothetical C++ build system when what it's doing works? How can a newer, higher-level library switch to some hypothetical build system if it depends on libraries like zlib?

Two additional factors complicate things:

  • In Linux, the distro packaging systems do provide standardized repositories of development library headers binaries, with (generally) standardized ABIs and an easy way of specifying a project's build dependencies. The existence of these (platform-specific) solutions reduces the impetus for a cross-platform solution.
  • With all of these complicating factors and pre-existing approaches, any attempt to establish a standard build system is going to run into the problem described in XKCD's "Standards":
    Situation: There are 14 competing standards.
    "14? Riculous! We need to develop one universal standard that covers everyone's use cases."
    Soon: There are 15 competing standards.

With all of that said:

There is some hope for the future. For example, CMake seems to be gradually replacing other build systems. Some of the Boost developers have started Ryppl, an attempt to do what you're describing.

2
  • I would change language differences to implementation differences
    – K-ballo
    Jan 10, 2013 at 17:35
  • 1
    Java is more non-standard than you think, I disagree with people saying that Java is "standard", Java requires the same test-cycle as all the other languages, maybe shorter than others, but my point is that Java it's absolutely not standard, look at how much time is passed to have the first official JDK on Mac, JDK 7 is the first official JDK release on MAC OS ! Today Java is really fragmented between Oracle/OpenJDK/Apple JVM, and this are only the top 3, without considering the past and other options. Jan 10, 2013 at 17:37
3

(also posted in linked question)

Right now I'm working on a tool able to automatically install all dependencies of a C/C++ app with exact version requirement :

  • compiler
  • libs
  • tools (cmake, autotools)

Right now it works, for my app. (Installing UnitTest++, Boost, Wt, sqlite, cmake all in correct order)

The tool, named «C++ Version Manager» (inspired by the excellent ruby version manager) is coded in bash and hosted on github : https://github.com/Offirmo/cvm

Any advices and suggestions are welcomed.

1
  • 1
    update : I'm no longer into C++ right now and this experimental tool development is paused.
    – Offirmo
    Jul 3, 2015 at 10:17
1

well, first off a system that resolves all the dependencies doesn't makes you productive by default, potentially it can make you even less productive.

Regarding the differences between languages I would say that in Java you have packages, which are handy when you have to organize and give a limited horizon to your code, in C++ you don't have an equivalent concept. In C++ all the libraries that can solve a symbol are good enough for the compiler, the only real requirement for a library is to have a certain ABI and to solve the required symbols, there are no automated ways that you can work to pick the right library, also solving a symbol it's just a matter of linking your function to the actual implementation, this doesn't even grant you that a correct linking phase will make your app work.

To this you can add important variables such as the library version, different implementations of the same library and different libraries with the same methods name.

An example is the Mesa library VS the opengl lib from the official drivers, or whatever lib you want that offers multiple releases and each one can solve all the symbols but probably there is a release that is more mature than the others and you can ask a compiler to pick the right one because they are all the same for its own purposes .

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.