I was tasked with installing PhantomJS 2.0 on an Ubuntu 14.04 VPS running with 2 GB of RAM. Online discussions on Github and Google Groups seemed to have pointed to the build process requiring much RAM to complete without error.
g++: internal compiler error: Killed (program cc1plus) Please submit a full bug report, with preprocessed source if appropriate. See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions. make: *** [.obj/inspector/InspectorAllInOne.o] Error 4 make: *** Waiting for unfinished jobs.... make: Leaving directory `/home/app/src/phantomjs-2.0.0/src/qt/qtwebkit/Source/WebCore' make: *** [sub-Target-pri-make_first-ordered] Error 2 make: Leaving directory `/home/app/src/phantomjs-2.0.0/src/qt/qtwebkit/Source/WebCore' make: *** [sub-Source-WebCore-WebCore-pro-make_first-ordered] Error 2
To overcome this error I checked the build.sh script and found that the script would discover the number of CPU cores you’re running on a machine and thus run that many concurrent build processes, thus using more memory. To overcome this you can run the script with the number of jobs specified.
$ ./build.sh --jobs 1
It turns out that this wasn’t anything new. The official build instructions actually advise to use the
--jobs 1 argument, I just missed this because I downloaded the ZIP file before proceeding. I did however find out that the ZIP file they have you download still results in error, whereas pulling the source from the ‘2.0’ branch of Github is building much better now.