0

First Question: What is the best way to support various 'standard' Linux platforms with a single C++11 binary? This binary uses a handful of third party libraries including boost, zlib, xml2, openssl (all of which I can build statically).

The binary must run on a variety of Linux platforms for x86_64: Ubuntu 16.04 and 14.04, Centos 7.2 and Debian. Soon it must run on Darwin x86_64 and Ubuntu 16.04 on a Beagle Bone Black.

The default versions of compilers, libstdc++ and libc runtimes vary quite a bit on these platforms. I have had some Linux success building on Ubuntu 14.04 with an upgraded (toolchain r-test) g++ 5.3 compiler using these compiler options (note not using the "-static" switch):

-static-libstdc++ -static-libgcc -D_GLIBCXX_USE_CXX11_ABI=0

However, this requires installing the upgraded 5.3 compiler on the host (default is 4.9 IIRC) and some runtime libs on the target platforms which is not preferred and risks issues with libc.so. If it should be determined that this sort of solution is best, then I would prefer to build on 16.04 with the newest g++ or clang with switches so the binary runs on older platforms with minimal changes to defaults. Yes, I know I am perhaps asking for the moon :)

Second question: instead of one binary, maybe one compiler and libc for all platforms including Darwin and Windows?

I was also considering an attempt to use musl to create a 'more consistently behaved binary. I could consider using clang instead of g++.

Anyone with experience/recommendations? I would very much like to avoid maintaining separate compilations and combinations of third-party libs and compilers and settings and upgrades for each platform (especially for Linux targets but pretty typical for different operating systems).

Using the same version of the same compiler and possibly the same version of a libc would be best but may not be possible: clang with musl?

Thanks

Vic
  • 1
  • 1
  • you're asking for the moon :-) that's why Docker is so popular nowadays, it tries to solve that specific problem, deploying everything you need in one isolated container. Personally I have never used it, but it seems like a nice solution. – dau_sama Jul 26 '16 at 23:40
  • Really? clang is available on all platforms: it would be a matter of identifying a common version of clang supported on all the target platforms. In terms of libc, there is a roadmap for windows support mentioned here: http://wiki.musl-libc.org/wiki/Roadmap so it does not seem so far fetched: not doable at the moment is more accurate? – Vic Jul 27 '16 at 20:03
  • things might work out of the box when you set up the whole thing. Then imagine you have to upgrade a third library dependency on one machine. That mean you'll have to do the same everywhere else to keep things working. On one distribution some library may be available before some other ones. And that's not even going to libc. You're right, doable but a big pain in the ass – dau_sama Jul 27 '16 at 23:29

0 Answers0