phantomjs/_posts/documentation/get-started/2000-01-02-build.md

76 lines
2.8 KiB
Markdown
Raw Normal View History

---
layout: post
title: Build
categories: docs docs-get-started
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.
## 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 2.0
./build.sh --qt-config "-I /usr/local/include/ -L /usr/local/lib/"
```
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
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.
On Debian-based distro (tested on Ubuntu 14.04), run:
```bash
sudo apt-get install g++ flex bison gperf ruby perl \
libsqlite3-dev libfontconfig1-dev libicu-dev libfreetype6 libssl-dev \
libpng-dev libjpeg-dev
```
Note: It is recommend also to install `ttf-mscorefonts-installer` package.
On Fedora-based distro (tested on CentOS 6), run:
```bash
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
```
Then, launch the build:
```bash
git clone git://github.com/ariya/phantomjs.git
cd phantomjs
git checkout 2.0
./build.sh
```
**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
**Note**: Supported toolchains: `MSVC2012` and `MSVC2013`.
**Note**: You must have Perl, Python, Ruby, and Git on PATH.
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 2.0
build.cmd
```
**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.
**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.