Skip to content

Build on Linux

syracine69 edited this page Apr 21, 2022 · 18 revisions

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

Table of Contents

Requirements

These instructions are for building the "linux99" branch (Chrome v99, CEF branch 4844).

Tested on Ubuntu 20.04 64-bit. Should work with newer versions as well.

Requirements:

  • Ubuntu 18.04
  • CMake 3.23.0
  • G++ 7.5.0
  • Ninja 1.10.2

Newer versions of tools should work, but if there are issues try downgrading.

Download PHP Desktop sources

Clone git repository and checkout the "linux99" branch.

Download CEF sources / prebuilt binaries

If you would like to use CEF prebuilt binaries then go to Spotify Automated CEF Builds. You have to download CEF for the same branch and revision that phpdesktop uses, see the CEF.Readme.txt file that includes version details. On Spotify page choose "Standard Distribution" binaries.

If you would like to build CEF from sources then see CEF Branches and building (external) wiki page.

Add GTK+ 3 Development dependency

For Ubuntu, type sudo apt-get install libgtk-3-dev to install GTK+ 3 development package.

Build cefclient and copy CEF files to phpdesktop

The CEF binaries downloaded from Spotify after extracting have the cef_binary_* directory. From now on we will refer to this directory as "cef_binary/" directory.

  1. Install CMake 3.23.0 or newer from http://www.cmake.org/ .
  2. Download Ninja from https://github.com/ninja-build/ninja/releases . Put ninja in your PATH or copy it to the build/ directory you will be creating in the next step.
  3. In "cef_binary/" directory create a "build" subdirectory directory and enter it
  4. Execute cmake -G "Ninja" -DCMAKE_BUILD_TYPE=Release -DUSE_SANDBOX=OFF ../
  5. Execute ninja cefclient
  6. Go to the "cef_binary/build/tests/cefclient/Release/" directory and run cefclient executable to see if it works fine
  7. Create "phpdesktop/build/bin/" directory and copy files and subdirectories from the "cef_binary/Release/" and "cef_binary/Resources/" directories. Exclude "chrome-sandbox" file.
  8. Copy "cef_binary/build/libcef_dll_wrapper/libcef_dll_wrapper.a" library to the "phpdesktop/build/lib/" directory (create it).
  9. 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 "CEF.Readme.txt" (eg. upgrading to a newer CEF) then delete the "phpdesktop/include/" directory and copy the "cef_binary/include/" directory there instead (ignore the "capi" subdirectory). Also overwrite "phpdesktop/CEF.Readme.txt" file with "cef_binary/README.txt".

Build PHP from sources

  1. Go to http://php.net/downloads.php and download PHP sources
  2. Extract them to build/php*/ directory
  3. If you want to build PHP with PostgreSQL extension, type sudo apt-get install libpqxx-dev to install needed library. Else edit phpdesktop/build-php.sh file and remove --with-pgsql switch to disable PostgreSQL extension
  4. You need to install some other libraries to compile PHP (7.4.28). Type sudo apt-get install libxml2-dev libsqlite3-dev.
  5. Run the phpdesktop/build-php.sh script. After script completes it will copy the php-cgi executable to the build/bin/ directory.

Build phpdesktop-linux project

  1. Go to the phpdesktop/ directory
  2. Edit Makefile file at root of project. Type find / -name gtk.h to find the GTK+3 include files directory. Add this path at the end of the line beginning with INCLUDES = ... -I/usr/include/gtk-3.0 (for example)
  3. Execute the ./build.sh command
  4. The phpdesktop executable will be created in the build/bin/ directory