Skip to content

Build on Windows

cztomczak edited this page Feb 8, 2016 · 21 revisions

This page provides step by step instructions on how to build PHP Desktop Chrome from sources.

Table of Contents generated with DocToc

Preliminary notes

Requirements:

  • Visual Studio 2010 or Visual C++ 2010 Express Edition which is free. Download VS2010Express1.iso and SP1. You may use newer versions up to VS2013, but .vcxproj/.sln files are available only for VS2010.

In case of any trobules see also Issue #64 which explains some of possible issues.

Download PHP Desktop sources

Clone the repository first.

As of this writing PHP Desktop Chrome has a few branches:

  • phpdesktop-chrome/ - this one includes Chrome 31 and is considered most stable
  • phpdesktop-chrome47/ - this one includes Chrome 47 (CEF branch 2526) and is a Release Candidate as of writing

You can apply further instructions to any of these branches.

Download CEF sources / prebuilt binaries

If you would like to use CEF prebuilt binaries then go to www.cefbuilds.com. You have to download CEF for the same branch and revision that phpdesktop uses. See phpdesktop-chrome/cef/README.txt or appropriate. Look for CEF version in that file. In our case for phpdesktop-chrome/ branch it is 3.1650.1562 as of writing. For the chrome47 branch it is "3.2526.1366.g8617e7c_windows32" as of writing.

  • Go to www.cefbuilds.com
  • Select branch 1650 > Windows 32bit > click "more revisions"
  • Now find CEF version that matches the one in README.txt. In our case it is "CEF Version: 3.1650.1562" as of writing. Click on the "2014-01-13 CEF 3.1650.1562 (39MB)" link to download and then extract it.

If you would like to build CEF from sources then see CEF Branches and building (external) wiki page. Recently Chromium has migrated from SVN to GIT and now building older branches (branch 1650 with CEF 3.1650.1562) from sources is not officially supported.

Build cefclient and copy CEF files to phpdesktop

The CEF binaries downloaded from cefbuilds.com after extracting have the "cef_binary_3.2526.1366.g8617e7c_windows32" directory. From now on we will refer to this directory as "cef_binary/".

  1. Install CMake 2.8.12.1 or newer from http://www.cmake.org/ . During installation choose an option to add cmake to user's PATH.
  2. Install Ninja from http://martine.github.io/ninja/ . Put ninja.exe in your PATH or copy it to the build/ directory you will be creating in next step.
  3. In "cef_binary/" create a "build" directory and enter it
  4. Execute "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\vcvars32.bat" (with quotes)
  5. Edit "cef_binary/CMakeLists.txt" and in the if(OS_WINDOWS) section add the /wd\"4481\" flag to CEF_COMPILER_FLAGS if it's missing (upstream CEF Issue #1642):
set(CEF_COMPILER_FLAGS          "/MP /Gy /GR- /W4 /WX /wd\"4100\" /wd\"4127\" /wd\"4244\" /wd\"4481\" /wd\"4512\" /wd\"4701\" /wd\"4702\" /wd\"4996\" ${CEF_DEBUG_INFO_FLAG}")
  1. Execute cmake -G "Ninja" -DCMAKE_BUILD_TYPE=Release ..
  2. If you get an error during linking "manifest authoring warning 81010002" then install Windows SDK 7.1 and copy "mt.exe" and "mt.exe.config" from "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin" to "C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin".
  3. Execute ninja cefclient
  4. Go to the "cef_binary/build/cefclient/" directory and run cefclient.exe to see if it works fine
  5. Create "phpdesktop-chrome/Release/" directory and copy files and subdirectories from the "cef_binary/Release/" and "cef_binary/Resources/" directories. Exclude ".lib" files. You may also copy cefclient.exe and cefclient.pdb from the "cef_binary/build/cefclient/" directory.
  6. Copy "cef_binary/build/libcef_dll/libcef_dll_wrapper.lib" and "cef_binary/Release/libcef.lib" to the "phpdesktop-chrome/lib/Release/" directory.
  7. To clean the build directory just delete it. To only clean ninja build and keep cmake files intact type ninja -t clean cefclient. If you need DEBUG binaries re-run commands starting from step 6 with DCMAKE_BUILD_TYPE=Debug and replace any "Release" directories mentioned with a "Debug" directory.

If you're building with version of CEF different from README.txt (eg. upgrading to a newer CEF) then delete the "phpdesktop-chrome/cef/include/" directory and copy the "cef_binary/include/" directory (ignore the "capi" subdirectory). Also overwrite "phpdesktop-chrome/cef/README.txt" file with "cef_binary/README.txt".

Download PHP binaries

Go to http://windows.php.net/download/ and:

  • For PHP 5.4 download "VC9 x86 Non Thread Safe" zip file
  • For PHP 5.6 download "VC11 x86 Non Thread Safe" zip file

Extract it and put binaries in phpdesktop-chrome/php/ directory.

If you want to support Windows XP download PHP 5.4 binaries and additionally move all DLL extensions from php/ext/ directory to the root php/ directory. See Issue 34 for why it needs to be done so. You will also have to create/modify php.ini and set extension_dir option:

extension_dir=./

Build phpdesktop-chrome project

  1. Go to phpdesktop-chrome/ directory
  2. Open phpdesktop-chrome.sln file in Visual Studio
  3. Change configuration to Release
  4. Build phpdesktop-chrome project. This will generate Release/phpdesktop-chrome.exe executable.
  5. Run phpdesktop-chrome.exe executable
Clone this wiki locally