Compiling PHP Source Codes in Vista with VC++ 2008
I tried to compile it in my "lovely" Vista machine following the guidance from this folk. Hopefully this can help you guys who are crazy enough (especially Sagi Arsyad) to jump in into deeper PHP exploration.
1. Preparation
- Visual Studio C++ 2008 (You can use free VC++ 2008 Express Edition, VCE++)
- Microsoft Windows SDK for Vista
- PHP Source Code from www.php.net (I am using PHP 5.2.6)
Ok, let start.....
First, just create your working directory, let say, D:/PHP-DEV then extract PHP source codes there. You need to have all libraries and header files of PHP and it's extensions that are not distributed together with PHP source package. We are lucky that Edin Kadribasic has collected it from many websites and share with us here. So, just download it and once you had the zip.zip file, copy it to your working directory and extract it there.
2. Compiling
Run Visual Studio 2008 Command Line Tools with Administrator right, then navigate to your PHP source codes folder. Run buildconf.bat then you will get message : "rebuilding configure.js". You can learn about it using the following command:
cscript /nologo configure.js --help
Lets try to use the following configuration:
cscript /nologo configure.js --without-xml --without-wddx --without-simplexml --without-dom --without-libxml --disable-zlib --without-sqlite --disable-odbc --disable-cgi --enable-cli --enable-debug --without-iconv
I got the following notification about bison.exe when I run it. Dont be panic, you should be patient enough with error messages when working with C++.. heheh. Just try to find bison.exe and flex.exe from zip.zip extracted folder, and copy it to your VC++ default path. In this case is : C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN.
Now, lets try to run your cscript again (blue color above), try find the <not found> files from the script results. In my case, I need to find where are : re2c.exe, zip.exe, lemon.exe, NewAPIs.h, and libjpeg.lib. You will not get everything just find in your first compilation (trust me). But at least when you have the following message, just take some 2 minutes break.
What next ??? just run nmake !!!. Bingo!! It is started to compile. It will take sometime to compile in your machine, grab a glass of coffee because you will get many errors (don't be crazy because of it). Indeed, it is your job as developer to understand what it is.
Ok, if you want to know more, open the makefile generated by the script then evaluate its content (easy to understand).
# Generated by configure.js
PHP_VERSION_STRING=5.2.6
CL=cl.exe
LINK=C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\link.exe
NMAKE=nmake.exe
MAKE_LIB=lib.exe
BISON=bison.exe
FLEX=flex.exe
MC=C:\Program Files\Microsoft SDKs\Windows\v6.0\bin\mc.exe
MT=C:\Program Files\Microsoft SDKs\Windows\v6.0\bin\mt.exe
PHP_PREFIX=C:\php5\debug
..... bla bla bla
Change whatever do you want in your cscript options and generated makefile then run it again and again till you get now error. I can only say, Good Luck dude !!
3. Enjoy Your Weekend with C++!
I will post more about creating PHP extension with VC++ later ..... stay tuned !!
Hope this helps - RAM