Building on windows
When building with PHP 5.3 - 5.4
- Windows SDK 6.1 Web Setup or DVD ISO
- Visual C++ 2010 Express Edition
When building PHP 5.5
Overall requirements
- wxWidgets 3.0.0
- PHP5 Sources
- wxPHP source code
- Read the README_MSW
- Download wxWidgets in one of the compressed formats of your choice
- Enable wxPosScriptDC
On wxWidgets source directory open:
include\wx\msw\setup.h
include\wx\setup_inc.h
then change 'wxUSE_POSTSCRIPT 0' to:
wxUSE_POSTSCRIPT 1
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
- 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 makefile.vc BUILD=release
If using Visual C++ 2012, open VS2012 x86 Native Tools Command Prompt:
cd wxWidgets_Installation_Path
cd build\msw
nmake -f makefile.vc BUILD=release
- 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
wxLogFormatter::FormatTime(long)const
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:
wxDEPRECATED_BUT_USED_INTERNALLY(
virtual void DoLog(wxLogLevel level, const char *szString, time_t t)
);
wxDEPRECATED_BUT_USED_INTERNALLY(
virtual void DoLog(wxLogLevel level, const wchar_t *wzString, time_t t)
);
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
- Download PHP:
To check available versions for download:
http://windows.php.net/download/
-
Create the directory:
c:\php-sdk
-
Download PHP 5 binary tools:
http://windows.php.net/downloads/php-sdk/
-
Extract the binary tools inside the directory c:\php-sdk leaving you with:
c:\php-sdk\bin c:\php-sdk\script
-
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_setvars.bat
bin\phpsdk_buildtree.bat phpdev
On Visual C++ 2012, open the Windows SDK 6.1 CMD Shell and do the following:
cd c:\php-sdk\
bin\phpsdk_setvars.bat
bin\phpsdk_buildtree.bat phpdev
-
Extract the php source files and place them on:
c:\php-sdk\phpdev\vc9\x86\php5.x.x
-
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 http://windows.php.net/downloads/php-sdk/
- PHP Source Changes
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;
with
#ifndef __WXMSW__
typedef unsigned short mode_t;
#endif
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
#endif
with
#ifdef WANT_LOGO
0 ICON win32\build\php.ico
#include <wx/msw/wx.rc>
#endif
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)
with
$(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.
-
Then compile the sources to see if everything is working:
cd c:\php-sdk\phpdev\vc9\x86\php5.x.x buildconf configure --disable-all --disable-zts --enable-cli --enable-cli-win32 nmake
Note: Make sure to read the README_MSW for some compilation and linking fixes which are also detailed on this page
-
Get wxPHP sources:
git clone git@github.com:wxphp/wxphp.git wxphp
-
Put the source code in the ext folder of your php build folder:
c:\php-sdk\phpdev\vc9\x86\php5.x.x\ext\wxwidgets
-
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 nmake
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 one produced from this build since these new executables include wxWidgets resources required by some components as describer 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:
[PHP_WXWIDGETS]
extension=php_wxwidgets.dll