Build failing on older Raspberry Pi?

I recently encountered this issue trying to build a fairly noddy app on an old Raspberry Pi2 (512MB RAM) - Internal Compiler Error

After waiting ages for a build to finish (>12 hours!!) only to see a Compiler error reported, I found that enabling a swapfile helped.
Raspberry Pi Forum - C++ internal compile error

Note, it’s never a good idea to have aswapfile on an SD card (it wares out their little write-cycles in no-time), but it’s OK to do it a few times.
Restrict your (re-)builds (I ended-up writing a little shell script to turn-on, make, then turn-of the swapfile)

To be honest, I only see this when I use gcc on the raspberry pi. Install clang and it will build without swap space:

make CXX=clang++
1 Like

Spot on! I created some swap space and that sorted it… though, TH it’s a very bad idea to do this on a SD card (I ended -up turning the swap file on/off in a little make script to save SD writes)

@fabian, (haven’t tried clan++ yet - I’d forgotten about this post) Have you tried to build on the Pi recently?

I’ve just tried a build on a Raspi Zero W (a Zero ith Wifi and Bluetooth and a camera i/f built-in) -

Following a fresh install of the latest Raspbian (installing libcurl4-gnutils-dev took a while - it kept clashing with the standard libcurl4-openssl-dev which i s installed by default…Had problems with pkg-config (not installed by default) but then got some very odd errors (random / spurious characters - which make me think the swapfile’s corrupt )

I always got strange random errors on the raspberry pi with gcc. I’m really not sure why. I could only ever get clang++ to work (or cross-compile from my Linux desktop to raspberry pi with gcc).