[CMake] How to build CMake so it works on an older Linux?

Patrick Griffiths patrick.griffiths at gmail.com
Thu Apr 5 09:43:03 EDT 2018


I had a similar problem on 14.04 and solved it by installing gcc 4.9 (other
version are also available) from the ubuntu-toolchain-r PPA.

This worked for me. YMMV:

$ sudo add-apt-repository ppa:ubuntu-toolchain-r/test
$ sudo apt-get update
$ sudo apt-get install gcc-4.9
$ sudo apt-get install g++-4.9

When building CMake I set the CXX and CC variables at the command line

$ CXX=g++-4.9 CC=gcc-4.9 ../path/to/bootstrap ...etc ..
$ CXX=g++-4.9 CC=gcc-4.9 make install

HTH
Patrick

On Thu, Apr 5, 2018 at 7:15 AM, Robert Maynard <robert.maynard at kitware.com>
wrote:

> The official CMake binaries do the same thing as you and build with a
> static libstdc++ and libgcc.
> As far as dependencies we use static builds of those too, with most
> being the version provided inside CMake, and an external openssl.
>
> You can find the more information on the exact flags we are using at:
> https://gitlab.kitware.com/cmake/cmake/blob/master/
> Utilities/Release/linux64_release.cmake
>
> On Thu, Apr 5, 2018 at 3:09 AM, Eric Wing <ewmailing at gmail.com> wrote:
> > Thanks for the responses. Yes, I just need this to run on Ubuntu 12.04
> > (and some other old Linux's in that era). Yes, I think the probably is
> > the libstdc++ dependency.
> >
> > As pointed out, it is really hard to get a newer compiler on Ubuntu
> > 12.04. I've been down this road before, and if memory serves, the gcc
> > bootstrapping process to get a newer compiler doesn't seem to work
> > with a compiler older than gcc 4.8. Same goes for clang, which also
> > weirdly relies on gcc 4.8 to bootstrap itself.
> >
> > Anyway, CMake seems to already know how to ship binaries that work
> > across Linux distros. I'm pretty sure they just statically linked
> > libstdc++ and libgcc. In fact, I just built it with -static-libstdc++
> > -static-libgcc on a newer Linux and tested it on 12.04 and it seemed
> > to work.
> >
> > But I wanted to know for sure how CMake is building their own binaries
> > in case there are subtle problems with what I did, and they have a
> > completely different way of building it, e.g. statically libmusl for C
> > and libc++ for C++, avoiding gcc entirely.
> >
> > Also, I did not take care of the libssl, libcrypto, and libz
> > dependencies. I'm curious in practice how much trouble these are. (My
> > recollection with zlib is that it is extremely stable and they care a
> > great deal about not breaking backwards compatibility. I don't know
> > about the others.)
> >
> > Thanks,
> > Eric
> > --
> >
> > Powered by www.kitware.com
> >
> > Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
> >
> > Kitware offers various services to support the CMake community. For more
> information on each offering, please visit:
> >
> > CMake Support: http://cmake.org/cmake/help/support.html
> > CMake Consulting: http://cmake.org/cmake/help/consulting.html
> > CMake Training Courses: http://cmake.org/cmake/help/training.html
> >
> > Visit other Kitware open-source projects at http://www.kitware.com/
> opensource/opensource.html
> >
> > Follow this link to subscribe/unsubscribe:
> > https://cmake.org/mailman/listinfo/cmake
> --
>
> Powered by www.kitware.com
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Kitware offers various services to support the CMake community. For more
> information on each offering, please visit:
>
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
>
> Visit other Kitware open-source projects at http://www.kitware.com/
> opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> https://cmake.org/mailman/listinfo/cmake
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20180405/8cbe5aee/attachment.html>


More information about the CMake mailing list