Skip to content

How to compile phantomjs for yourself

Yossi Rafelson edited this page Jan 17, 2018 · 11 revisions

So you've finally lost your marbles and want to compile the latest version of phantomjs for yourself.

based on http://phantomjs.org/build.html

sudo apt-get install git build-essential g++ flex bison gperf ruby perl libsqlite3-dev libfontconfig1-dev libicu-dev libfreetype6 libssl-dev libpng-dev libjpeg-dev python libx11-dev libxext-dev ttf-mscorefonts-installer

git clone git://github.com/ariya/phantomjs.git
cd phantomjs
git checkout 2.1.1
git submodule init
git submodule update

open src/phantom.cpp
find the line:
return new CookieJar(filePath, this);
(around line 300 or so) and replace it with:
return new CookieJar(m_config.cookiesFile() != "" ? m_config.cookiesFile() : filePath,this);
save and exit the editor

if you are using python3:
open src/qt/qtwebkit/Source/JavaScriptCore/disassembler/udi86/ud_opcode.py
find the 3 lines that contain:
(int(v) / 32)
and replace with double slashes // like so:
(int(v) // 32)
This is how floor division is done in python3, while this seems to be written with the python2 (and most c languages) division in mind.
save and exit the editor

./build.py

settle in, this will take a loooong time