Home > Article > Backend Development > 在Windows系统中使用VC9、VC11编译32位、64位PHP及其扩展
项目中需要使用runkit模块实现AOP,但是团队成员的开发环境都是Windows,而runkit模块官方没有提供Windows环境下的dll扩展,只能自己编译。
下面是编译过程的分类总结。(操作系统环境为Windows 10 64位中文旗舰版)
cd c:\php-sdk\
bin\phpsdk_buildtree.bat phpdev
会在c:\php-sdk文件夹下生成phpdev文件夹,其中包含vc6、vc8、vc9子文件夹。
如果使用MSVC11编译PHP,就复制c:\php-sdk\phpdev\vc9到c:\php-sdk\phpdev\vc11。
如果使用MSVC14编译PHP,就复制c:\php-sdk\phpdev\vc9到c:\php-sdk\phpdev\vc14。
http://download.microsoft.com/download/a/4/2/a4282359-1d35-4648-a7a7-d85e3bfe81ac/6.0.6001.16621.148.WindowsSDK_LonghornServer_IDS04_idw.WindowsSDK.DVD.Release.iso 下载离线安装包。
如需编译32位版本,在安装Windows SDK 6.1时,要注意选择安装x86编译器,否则会出现找不到cl.exe的问题。下面是具体的编译步骤,有些内容会出现重复,是为了让偷懒的同学按图索骥,有样学样:)
可能遇到的问题:
regsvr32 %WINDIR%\System32\jscript.dllregsvr32 %WINDIR%\SysWOW64\jscript.dll
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\.js]@="jsfile"
[HKEY_CLASSES_ROOT\.js\PersistentHandler]@="{5e941d80-bf96-11cd-b579-08002b30bfeb}"
[HKEY_CLASSES_ROOT\JSFile]
"FriendlyTypeName"=hex(2):40,00,25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,\
00,6f,00,6f,00,74,00,25,00,5c,00,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,\
32,00,5c,00,77,00,73,00,68,00,65,00,78,00,74,00,2e,00,64,00,6c,00,6c,00,2c,\
00,2d,00,34,00,38,00,30,00,34,00,00,00
[HKEY_CLASSES_ROOT\JSFile\ScriptEngine]@="JScript"
[HKEY_CLASSES_ROOT\JSFile\ScriptHostEncode]@="{85131630-480C-11D2-B1F9-00C04F86C324}"
[HKEY_CLASSES_ROOT\JSFile\Shell]@="Open"
[HKEY_CLASSES_ROOT\JSFile\Shell\Open\Command]
@=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,00,25,\
00,5c,00,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,57,00,53,00,\
63,00,72,00,69,00,70,00,74,00,2e,00,65,00,78,00,65,00,20,00,22,00,25,00,31,\
00,22,00,20,00,25,00,2a,00,00,00
[HKEY_CLASSES_ROOT\JSFile\Shell\Open2]
@=hex(2):4f,00,70,00,65,00,6e,00,20,00,26,00,77,00,69,00,74,00,68,00,20,00,43,\
00,6f,00,6d,00,6d,00,61,00,6e,00,64,00,20,00,50,00,72,00,6f,00,6d,00,70,00,\
74,00,00,00
"MUIVerb"=hex(2):40,00,25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,\
6f,00,74,00,25,00,5c,00,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,\
00,77,00,73,00,68,00,65,00,78,00,74,00,2e,00,64,00,6c,00,6c,00,2c,00,2d,00,\
34,00,35,00,31,00,31,00,00,00
[HKEY_CLASSES_ROOT\JSFile\Shell\Open2\Command]
@=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,00,25,\
00,5c,00,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,43,00,53,00,\
63,00,72,00,69,00,70,00,74,00,2e,00,65,00,78,00,65,00,20,00,22,00,25,00,31,\
00,22,00,20,00,25,00,2a,00,00,00
[HKEY_CLASSES_ROOT\JSFile\Shell\Print\Command]
@=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,00,25,\
00,5c,00,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,4e,00,6f,00,\
74,00,65,00,70,00,61,00,64,00,2e,00,65,00,78,00,65,00,20,00,2f,00,70,00,20,\
00,25,00,31,00,00,00
[HKEY_CLASSES_ROOT\JSFile\ShellEx\DropHandler]@="{60254CA5-953B-11CF-8C96-00AA00B8708C}"
[HKEY_CLASSES_ROOT\JSFile\ShellEx\PropertySheetHandlers\WSHProps]@="{60254CA5-953B-11CF-8C96-00AA00B8708C}"
[HKEY_CLASSES_ROOT\JScript]@="JScript Language"
[HKEY_CLASSES_ROOT\JScript\CLSID]@="{f414c260-6ac0-11cf-b6d1-00aa00bbbb58}"
[HKEY_CLASSES_ROOT\JScript\OLEScript]
PS:
实践过程中,主要参考如下三篇文章,仅向原作者致谢: