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.

3
  • @goldilocks I don't understand what you mean. I don't see any arm binaries there.
    – Szabolcs
    Commented Nov 5, 2020 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
    Commented Nov 5, 2020 at 23:08
  • Just noting that this one does not seem to work on an RPi 1: snapcraft.io/install/cmake/raspbian
    – Szabolcs
    Commented Nov 6, 2020 at 8:22

1 Answer 1

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.

2
  • 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
    Commented Nov 6, 2020 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. Commented Nov 8, 2020 at 11:54

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.