©
本文档使用 PHP中文网手册 发布
本章讲述了在 Windows 下如何使用 Microsoft 的工具编译 PHP。要在 CygWin 中编译 PHP,请参考 Unix 系统下的安装一章。
具体内容见:» http://wiki.php.net/internals/windows/stepbystepbuild。
[#1] mail at tonywilk dot co dot uk [2014-01-08 18:03:17]
Building PHP on Windows 7 with Visual Studio 2010 installed...
- this differs slightly from the stepbystepbuild info and it worked for me :)
0. make a directory and unpack both of these into it:
php-5.4.23-src.zip (should have a win32 directory in it)
php-sdk-binary-tools-20110915
1. Run Visual Studio 2010 command prompt
2. CD to your php source root directory
3. set mc="C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\mc" - or wherever it is on your machine
4. vcvars32
5. set path=your_php_source_directory\bin;%PATH%
6. buildconf
7. configure --help
this gets you a list of all the options, then... (e.g.)
8. configure --disable-all --enable-cgi --with-sqlite3
9. nmake
10. results should be in Release_TS
in this example, all we need is php-cgi.exe and php5ts.dll
[#2] buda [2011-11-15 14:10:19]
Using --enable-snapshot-build when setting the configure command requires you to also set --disable-static-analyze (Win7 64Bit, VC9 Express, SDK 6.1) for otherwise you will run into a fatal compiler error "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\Include\tchar.h(1659) : fa
tal error C1001: Interner Compilerfehler.
(Compilerdatei "msc1ast.cpp", Zeile 1411)"
(see also https://bugs.php.net/bug.php?id=55779)
[#3] Joel Low [2010-02-27 02:12:29]
To build everything in the distribution, pass --enable-snapshot-build to configure.js. In addition, you may like to use "snap" as the nmake target. If you intend to build the PHP Windows Installer, WiX source files can be obtained from http://svn.php.net/repository/php/win-installer/.
[#4] michal dot kocarek at brainbox dot cz [2009-08-17 11:10:00]
PHP extensions can be compiled statically or shared.
- Shared compilation creates a well-known php_*.dll file.
- Static compilation puts the extension directly into PHP (therefore it does not need to be loaded and cannot be unloaded)
You can switch whether to compile given extension statically or as library by adding =static or =shared to the extension in configure.js command during the compilation.
configure --enable-http=static --with-openssl=shared
// http extension will be included in PHP
// openssl extension will be compiled as separate DLL
[#5] Bas van Beek [2009-03-12 06:50:45]
If trying to compile the code (Windows XP, SDK v6.1) and you get the following types of errors:
c:\phpdev\php-5.2.9\main\php_network.h(128) : warning C4005: 'POLLIN' : macro redefinition
c:\program files\microsoft sdks\windows\v6.1\include\winsock2.h(1495) :
see previous definition of 'POLLIN'
c:\phpdev\php-5.2.9\main\php_network.h(129) : warning C4005: 'POLLPRI' : macro redefinition
c:\program files\microsoft sdks\windows\v6.1\include\winsock2.h(1496) :
see previous definition of 'POLLPRI'
c:\phpdev\php-5.2.9\main\php_network.h(130) : warning C4005: 'POLLOUT' : macro redefinition
c:\program files\microsoft sdks\windows\v6.1\include\winsock2.h(1499) :
see previous definition of 'POLLOUT'
c:\phpdev\php-5.2.9\main\php_network.h(131) : warning C4005: 'POLLERR' : macro redefinition
c:\program files\microsoft sdks\windows\v6.1\include\winsock2.h(1502) :
see previous definition of 'POLLERR'
c:\phpdev\php-5.2.9\main\php_network.h(132) : warning C4005: 'POLLHUP' : macro redefinition
c:\program files\microsoft sdks\windows\v6.1\include\winsock2.h(1503) :
see previous definition of 'POLLHUP'
c:\phpdev\php-5.2.9\main\php_network.h(133) : warning C4005: 'POLLNVAL' : macro redefinition
c:\program files\microsoft sdks\windows\v6.1\include\winsock2.h(1504) :
see previous definition of 'POLLNVAL'
NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN
\cl.exe"' : return code '0x2'
Stop.
You can alter the Makefile and add the following switch to CFLAGS:
/D _WIN32_WINNT
[#6] php at tattodecastro dot com [2007-12-06 16:14:05]
If you are getting the following error message:
Input Error: There is no script engine for file extension ".js"
with Visual Studio 2005 Command Prompt or similar, try to add "/e:jscript" to the command line.
Something like:
cscript /nologo /e:jscript win32/build/buildconf.js
It worked for me, I hope it helps.
[#7] axel at kollmorgen dot net [2007-05-27 06:13:12]
>>Compiling using Visual Studio .NET will create binaries dependent of msvcp71.dll
>
> Only if you compile with the wrong runtime library.
if this is so easy, please tell us how you managed to *not* create dependencies on msvcp71.dll/msvcr80/... using Visual C++ .NET 2000/2003/2005. thanks!
[#8] [2006-12-10 06:09:10]
>> Compiling using Visual Studio .NET will create binaries dependent of msvcp71.dll
Only if you compile with the wrong runtime library.
[#9] zbowden at vt dot edu [2006-05-12 07:12:09]
When running "cscript /nologo configure.js" 5.x on Windows
2000 or XP, if you get the following error:
Microsoft JScript runtime error: Object doesn't support this
property or method
You need to have at least version 5.6 of WSH.
This is necessary because configure.js will use the .Exec()
method of the WScript.Shell.
This evidently didn't exist until 5.6?
You can download WSH 5.6 here:
http://www.microsoft.com/downloads/details.aspx?
FamilyID=c717d943-7e4b-4622-86eb-95a22b832caa&DisplayLang=en