Skip to content

Building on windows

Jefferson González edited this page Jun 15, 2014 · 20 revisions


When building with PHP 5.3 - 5.4

When building PHP 5.5

Overall requirements

  • wxWidgets 3.0.0
  • PHP5 Sources
  • wxPHP source code
  • Read the README_MSW.txt

Download and install wxWidgets 3.0.0

  1. Download wxWidgets in one of the compressed formats of your choice

7 Zip or Zip

After downloading the sources extract them into a directory like C:\wxWidgets-3.0.0

  1. Enable wxPostScriptDC

On wxWidgets source directory open:


then change 'wxUSE_POSTSCRIPT 0' to:


Crashes where occurring on Windows XP and the culprit was the "COMPILER_TLS" feature. So to fix the crashes on windows xp is needed to disable wxUSE_COMPILER_TLS by setting it to 0:


I'm not really sure but I noticed that changing include\wx\msw\setup.h didn't had any effect on the final setup.h generated for the compiled libraries so just in case I also recommend to modify include\wx\setup_inc.h

  1. Compile wxWidgets

If using Visual C++ 2008, open Windows SDK 6.1 CMD Shell:

    setenv /release /x86 /xp
    cd wxWidgets_Installation_Path
    cd build\msw
    nmake -f BUILD=release

If using Visual C++ 2012, open VS2012 x86 Native Tools Command Prompt:

    cd wxWidgets_Installation_Path
    cd build\msw
    nmake -f BUILD=release
  1. Uncomment or remove some declarations

Linking errors where produced when linking wxphp to wxwidgets from some deprecated methods that seemed to be implemented on log.cpp but strangely enough are producing linking errors.

Note: You should do this after wxWidgets was compiled and before compiling the wxPHP extension.

Fix: Comment out the following declarations/prototypes from the wxwidgets include/wx/log.h


The line should look like this:

    virtual wxString FormatTime(time_t t) const;

wxLog::DoLog(unsigned long,wchar_t const *,long)

wxLog::DoLog(unsigned long,char const *,long)

The lines should look like these:

        virtual void DoLog(wxLogLevel level, const char *szString, time_t t)

        virtual void DoLog(wxLogLevel level, const wchar_t *wzString, time_t t)

Modify conflicting mode_t declaration on include/wx/filefn.h

    #if defined(__VISUALC__) || defined(__DIGITALMARS__)
        typedef int mode_t;

Previous code should end like

    #ifndef PHP_WIN32
        #if defined(__VISUALC__) || defined(__DIGITALMARS__)
            typedef int mode_t;
        #define mode_t int

Download and Install PHP sources

NOTE: Compilation has been tested against PHP 5.3 and 5.5 it should work with any 5.3.x - 5.5.x version of php

  1. Download PHP:

To check available versions for download:

  1. Create the directory:

  2. Download PHP 5 binary tools:

  1. Extract the binary tools inside the directory c:\php-sdk leaving you with:

  2. Prepare for building

On Visual C++ 2008, open the Windows SDK 6.1 CMD Shell and do the following:

    setenv /release /x86 /xp
    cd c:\php-sdk\
    bin\phpsdk_buildtree.bat phpdev

On Visual C++ 2012, open VS2012 x86 Native Tools Command Prompt:

    cd c:\php-sdk\
    bin\phpsdk_buildtree.bat phpdev
  1. Extract the php source files and place them on:

  2. Install additional dependencies (Optional)

On the c:\php-sdk\phpdev\vc9\x86 directory you will see a folder called deps, there you can place additional libraries required to build some of the php extensions which you find for your PHP specific version on

  1. PHP Source Changes

(This change isn't needed anymore) mode_t is defined on wxWidgets and PHP at the same time which causes a re-declaration conflict to the compiler.

Fix: On TSRM/tsrm_virtual_cwd.h substitute:

    typedef unsigned short mode_t;


    #ifndef __WXMSW__
    typedef unsigned short mode_t;

wx.rc Needed on php.exe

It seems that some wxWidgets components rely on cursors and icons that need to be embedded on the main application executable, like for example wxStyledTextCtrl. In this case the application executable is php.exe or php-win.exe

Steps to include wx.rc on these executables:

Open: win32/build/template.rc and replace

    #ifdef WANT_LOGO
    0 ICON win32\build\php.ico


    #ifdef WANT_LOGO
    0 ICON win32\build\php.ico
    #include <wx/msw/wx.rc>

in order to only include the wx.rc file when the system is building the php.exe or php-win.exe.

Modify: win32/build/confutils.js and replace all occurences of



    $(RC) /I PATH_TO_WXWIDGETS\\include

where PATH_TO_WXWIDGETS can be C:\\wxWidgets. This is to ensure that the resource compiler fines the file wx.rc.

Important: If this steps are omitted the php executable will crash each time a wxWidgets component that relies on some specific resources is loaded.

  1. Then compile the sources to see if everything is working:

     cd c:\php-sdk\phpdev\vc9\x86\php5.x.x
     configure --disable-all --disable-zts --enable-cli --enable-cli-win32

Compile wxPHP

Note: Make sure to read the README_MSW.txt for some compilation and linking fixes which are also detailed on this page

  1. Get wxPHP sources:

     git clone wxwidgets
  2. Put the source code in the ext folder of your php build folder:

  3. On your currently opened development command prompt:

     cd c:\php-sdk\phpdev\vc9\x86\php5.x.x
     nmake clean
     buildconf --force
     configure --disable-all --disable-zts --enable-cli --enable-cli-win32 --with-wxwidgets=C:\wxWidgets_installation_path

Copy the resulting php_wxwidgets.dll file on the Release directory to the php extensions directory of your current PHP 5 VC9 X86 Non Thread Safety setup. Also don't forget to replace your original php executables with the ones produced from this build since these new executables include wxWidgets resources required by some components as described before on the PHP Source Changes step.

If you want the wxWidget extension to be automatically loaded, add the following lines to the end of your php.ini:


Create Setup File with Inno Setup

Theres a inno script that is distributed with the sources so you can create your own setup file or help the project by building development snapshots. In order to create the setup you will need to install inno setup and the inno script preprocessor. You can download the inno setup pack installer which includes everything you will need.

  1. Download an official precompiled package of php for windows that matches your current build.

  2. Extract the php zip file and rename the containing folder to "php". Then place it inside: c:\php-sdk\phpdev\vc9\x86\php5.x.x\ext\wxwidgets\tools\inno_setup\

  3. Copy php.exe, php-win.exe and php_wxwidgets.dll you just built into the php directory you just copied into the inno_setup directory.

  4. Place php_wxwidgets.dll into the ext directory and rename php.exe into wxphp.exe and php-win.exe into wxphp-win.exe. (If you want the executables to have the wxphp icon you must build with the wxphp icon replacing original php one which is stored inside win32\build\php.ico at the php source root directory)

  5. Open script.iss with inno setup or by double clicking the file and press compile. After it finishes you should see a wxphp-x.x.x.x.exe file inside the inno_setup directory.

Thats all :)