Skip to content
This repository has been archived by the owner on May 30, 2023. It is now read-only.

Commit

Permalink
Issue #12897: Build instructions for 2.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
ariya committed Jan 31, 2015
1 parent faee6bd commit a52898d
Showing 1 changed file with 24 additions and 62 deletions.
86 changes: 24 additions & 62 deletions _posts/documentation/get-started/2000-01-02-build.md
Expand Up @@ -7,107 +7,69 @@ permalink: build.html

**Warning**: Compiling PhantomJS from source takes a long time, mainly due to thousands of files in the WebKit module. With 4 parallel compile jobs on a modern machine, the entire process takes roughly 30 minutes. It is highly recommended to download and install the ready-made [binary package]({{ site.url }}/download.html) if it is available.

**Note**: This is the instruction to build the stable version of PhantomJS (1.9 as of now). For the bleeding-edge version, refer to the [PhantomJS 2 wiki](https://github.com/ariya/phantomjs/wiki/PhantomJS-2).

## Mac OS X

Install [Xcode](https://developer.apple.com/xcode/) and the necessary SDK for development (gcc, various tools, libraries, etc).

```bash
git clone git://github.com/ariya/phantomjs.git
cd phantomjs
git checkout 1.9
./build.sh
git checkout 2.0
./build.sh --qt-config "-I /usr/local/include/ -L /usr/local/lib/"
```

This produces a static build `bin/phantomjs`. This is a self-contained executable, it can be moved to a different directory or another machine.
This produces a statically built `bin/phantomjs`. This is a self-contained executable, it can be moved to a different directory or another machine.

## Linux

### Apt-based systems

```bash
sudo apt-get update
sudo apt-get install build-essential chrpath git-core libssl-dev libfontconfig1-dev libxft-dev
git clone git://github.com/ariya/phantomjs.git
cd phantomjs
git checkout 1.9
./build.sh
```
####Tested on:
+ Ubuntu (10.04, 11.04, 12.04, 13.10, 14.04)
+ Debian (7.6)
First, install the development packages of the following tools and libraries: GNU C++ compiler, bison, flex, gperf, Perl, Ruby, SQLite, FreeType, FontConfig, OpenSSL, and ICU. The actual package names may vary from one distribution to another.

### yum-based systems
On Debian-based distro (tested on Ubuntu 14.04), run:

```bash
sudo yum install gcc gcc-c++ make git openssl-devel freetype-devel fontconfig-devel
git clone git://github.com/ariya/phantomjs.git
cd phantomjs
git checkout 1.9
./build.sh
sudo apt-get install g++ flex bison gperf ruby perl \
libsqlite3-dev libfontconfig1-dev libicu-dev libfreetype6 libssl-dev \
libpng-dev libjpeg-dev
```

**Note**: To create an RPM package (EC2 AMI, CentOS, or RHEL), make sure `rpm-build` package is installed and then
run the following _after_ a successful build:
Note: It is recommend also to install `ttf-mscorefonts-installer` package.

On Fedora-based distro (tested on CentOS 6), run:

```bash
cd rpm
./mkrpm.sh phantomjs
sudo yum -y install gcc gcc-c++ make flex bison gperf ruby \
openssl-devel freetype-devel fontconfig-devel libicu-devel sqlite-devel \
libpng-devel libjpeg-devel
```

####Tested on:
+ Amazon EC2 AMI (release 2011.09, 2012.03)
+ CentOS/RHEL 6

### emerge-based systems
Then, launch the build:

```bash
sudo emerge chrpath fontconfig dev-libs/openssl
git clone git://github.com/ariya/phantomjs.git
cd phantomjs
git checkout 1.9
git checkout 2.0
./build.sh
```

---

**Note 1**: `build.sh` by default will launch parallel compile jobs depending on the available CPU cores, e.g. 4 jobs on a modern hyperthreaded dual-core processor. If necessary, e.g. when building on a virtual machine/server or other limited environment, reduce the jobs by passing a number, e.g `./build.sh --jobs 1` to set only one compile job at a time.

**Note 2**: Compile time for Ubuntu 12.04 running on Amazon EC2 _M1 Extra Large_ (m1.xlarge, 4 cores): 20 minutes, _M1 Large_ (m1.large, 2 cores): 50 minutes, _M1 Medium_ (m1.medium, 1 core): 100 minutes.
**Note**: `build.sh` by default will launch parallel compile jobs depending on the available CPU cores, e.g. 4 jobs on a modern hyperthreaded dual-core processor. If necessary, e.g. when building on a virtual machine/server or other limited environment, reduce the jobs by passing a number, e.g `./build.sh --jobs 1` to set only one compile job at a time.

## Windows

Install [Microsoft Visual C++](http://www.microsoft.com/visualstudio/), either version 2010 or 2008 (the [Express edition](http://www.microsoft.com/visualstudio/en-us/products/2010-editions/express) should work just fine).
**Note**: Supported toolchains: `MSVC2012` and `MSVC2013`.

Install [ActivePerl 5](http://www.activestate.com/activeperl/) (the free Community Edition should work fine).
**Note**: You must have Perl, Python, Ruby, and Git on PATH.

First step is to build OpenSSL static library. Go to [openssl.org/source](http://www.openssl.org/source/) and download the source package (tested with version 1.0.1). Unpack the package to a working directory, e.g. `C:\openssl`. Configure and build OpenSSL:

```bash
perl Configure VC-WIN32 no-asm --prefix=C:\openssl
ms\do_ms
nmake -f ms\nt.mak install
```

Get PhantomJS source code:
Use Visual Studio Command Prompt, run in the top directory. The results will go into `bin`:

```bash
git clone git://github.com/ariya/phantomjs.git
cd phantomjs
git checkout 1.9
git checkout 2.0
build.cmd
```

Edit file `src\qt\preconfig.cmd` and change OPEN_SSL_DIR variable to point to the OpenSSL working directory.

Finally, compile PhantomJS:
**Note**: `git.exe` has to be on PATH. If you are using a wrapper (`git.cmd`, `git.bat`, etc.) modify `build.cmd` and replace `git.exe` with whatever you have on the PATH.

```bash
cd src\qt
preconfig.cmd
cd ..\..
src\qt\bin\qmake -r
nmake
```
**Note**: Enabling incremental linking will make the linkage process faster.

This produces a static build `bin/phantomjs.exe`. This is a self-contained executable, it can be moved to a different directory or another machine.

0 comments on commit a52898d

Please sign in to comment.