3

I have a Raspberry Pi 1B with Raspbian Buster. It comes with cmake 3.13. I need version 3.16 or later. How can I obtain this version of cmake?

What I tried so far:

I attempted to compile cmake from source. Unfortunately, the linker crashes during the linking step. I suspect it is because of an out-of-memory condition. In the end I just see:

collect2: fatal error: ld terminated with signal 9 [Killed]

I was not not able to find pre-built binaries for this platform and I do not have a newer Raspberry Pi with more memory.

Szabolcs
  • 672
  • 2
  • 6
  • 17
  • @goldilocks I don't understand what you mean. I don't see any arm binaries there. – Szabolcs Nov 05 '20 at 22:54
  • Whoops! Sorry, when I first glanced at this I thought "I attempted to compile..." something else and you thought using 3.16 would make it better. If you've already tried a source compile, that sucks. – goldilocks Nov 05 '20 at 23:08
  • Just noting that this one does not seem to work on an RPi 1: https://snapcraft.io/install/cmake/raspbian – Szabolcs Nov 06 '20 at 08:22

1 Answers1

3

Set up a swap file / partition and try again. You can get rid of the swap once the compilation is over, but I'd keep it: if you're going to use cmake to build more stuff, you'll likely need it again.

Another trick which drastically reduces the linker memory requirements (at the expense of worse performance of the built binaries) is to disable link-time optimization with -fno-lto.

Dmitry Grigoryev
  • 27,928
  • 6
  • 53
  • 144
  • It turns out that it may have been my mistake: I was using ninja instead of make, assuming it would be more efficient. It turns out that ninja starts two build commands in parallel even on this single-core machine. I made two changes: use ninja -j1 and compile as MinSizeRel. Now it succeeded. I don't know which of the two is responsible for the success, and given the compilation times, I woudn't want to re-run it to find out ... LTO was not enabled. – Szabolcs Nov 06 '20 at 11:12
  • @Szabolcs I think you will find out soon enough, once you start using cmake to build bigger projects. And yeah, it's pretty normal that cmake doesn't use LTO, it's not the kind of software where performance really counts. You'll likely to see this option when building a game or a web browser. – Dmitry Grigoryev Nov 08 '20 at 11:54