Low Resource Compiling Error Fix

When you are using a budget vps, and sometimes you need just a little more juice than your box can give to you I may have a simple, while temporary, solution.

When you exhaust your RAM resource on a budget VPS you can get all sorts of errors that can lead to failures in your compilation or errors that are hard to diagnose.

For example. I was compiling a Bitcoin daemon on my Ubuntu 13.04 VPS with minimal Ram (512MB to be exact) and ran into this error.

URCE=2  -MMD -MF obj/init.d -o obj/init.o init.cpp
g++: internal compiler error: Killed (program cc1plus)

After hours of trying to figure out exactly what was going on, I found out that it was indeed my RAM or lack there of. So, the solution.

A temporary swap. This can be executed to allow yourself a swap for your ram in order to give you that extra juice to compile whichever program you are trying to compile.

It can be done as follows:

sudo dd if=/dev/zero of=/swapfile bs=64M count=16
sudo mkswap /swapfile
sudo swapon /swapfile

After you have finished compiling (hooray for success) you need to disable the swap with the following:

sudo swapoff /swapfile
sudo rm /swapfile

And that should fix this error for you. It is an easy problem to solve, and can be a PITA if you don't know what is going on.

So next time you get an error similar to this while compiling something. Give this a try, it may just save you a lot of grief.


QR Code
QR Code compile_error_resourcefix (generated for current page)