下面是在看《Sams.Extending.and.Embedding.PHP》的第4章 编译PHP的一些实践记录,相应中文版 地址 http://www.walu.cc/phpbook/4.1.md,书上关于windows部分的资料和命令是05年的,已经很老了下面找到PHP官方关于php在windows下编译的说明进行操作和记录。php官方windows编译说明: https://wiki.php.net/internals/windows/stepbystepbuild
下面没有按照官方的要求安装windows sdk6.1,而是安装的VS2008,启动Visual Studio命令提示(2010)后无法执行下面的语句,
  1. PHP 5.2, 5.3 and 5.4:

    setenv /x86 /xp /release
    

  2. PHP 5.5+:

    setenv /x86 /2008 /release
    

提示“setenv”命令不存在,直接放弃这个操作,执行如下操作设置windows的编译环境,
  1. bin\phpsdk_setvars.bat
    

  2. 以下命令仅仅在第一次建立目录树阶段使用
    bin\phpsdk_buildtree.bat php53dev
    

然后将php-5.3.17放到相对的php53dev\vc9\x86\php5.3-xyz路径,如果需要使用第三方库(第三方库包含大多数php扩展使用的依赖库文件),可以从http://wiki.php.net/internals/windows/libs这里的地址找到下载,然后放到D:\phpDev\php53dev\vc9\x86下的“deps”目录里面。进入源码目录,执行buildconf命令建立configure文件,就可以开始类似linux下的编译工作了。

cd  d:\phpDev>cd php53dev\vc9\x86\php-5.3.17
使用如下编译参数将只会编译--enable-$remains部分的扩展,其他都会被禁止掉
configure --disable-all --enable-cli --enable-$remains
然后执行
nmake
如果一切顺利,现在就可以在D:\phpDev\php53dev\vc9\x86\php-5.3.17\Release_TS下面找到编译的文件了。
如果需要增加扩展重新编译,需要下载 http://windows.php.net/downloads/php-sdk/目录下的对应deps-5.3-vc9-x86.7z,并按照目录格式要求放到 D:\phpDev\php53dev\vc9\x86目录下
带上enable-debug 会导致编译的结果在Debug_TS下面,同时编译的文件可以通过VC来调试,编译为独立的dll文件需要给每个扩展添加shared参数
下面是修改版的PHP官方windows下的编译参数, 可以编译出大多数的dll并且直接打包成zip文件。
configure --enable-cli  --enable-snapshot-build   --enable-debug-pack --without-mssql  --without-pdo-mssql  --without-pi3web  --enable-object-out-dir=../obj/ --enable-com-dotnet=shared --with-mcrypt=static  --disable-static-analyze
然后是nmake clean , nmake 就OK了,编译后的生成文件都在上级目录的obj目录下。
下面是对部分configure参数的说明:
--enable-snapshot-build       Build a snapshot; turns on everything i and ignores build errors
建立快照版本,打开所有编译项同时忽略编译错误
--enable-one-shot             Optimize for fast build - best for rele  snapshot builders, not so hot for
edit-and-rebuild hacking
--with-cygwin                 Path to cygwin utilities on your system
使用cygwin系统工具
--enable-object-out-dir       Alternate location for binary objects during build
二进制对象在编译后的目录
--enable-debug                Compile with debugging symbols
编译时带调试信息
--enable-debug-pack           Release binaries with external debug symbols
(--enable-debug must not be specified)
--disable-zts                 Thread safety
--with-prefix                 where PHP will be installed
--with-mp                     Tell VC9+ use up to [n,auto,disable] processes
for compilation
是否使用多处理器编译
--with-php-build              Path to where you extracted the development libraries
(http://wiki.php.net/internals/windows/   Assumes that it is a sibling of this so
dir (..\deps) if not specified
指定在windows下编译php需要的开发库
--with-extra-includes         Extra include path to use when building  everything
编译php时使用的其他包含路径
--with-extra-libs             Extra library path to use when linking  everything
链接时使用的其他包含库路径
--disable-ipv6                Disable IPv6 support (default is turn it on if available)
--enable-fd-setsize           Set maximum number of sockets for selected(2)
为selected设置最大数量的socket数量
--enable-zend-multibyte       Enable Zend multibyte encoding support
François Laupretre came next, with a fix for href="http://bugs.php.net/42396">bug #42396 in PHP 5.  He wrote that the configuration option --enable-zend-multibyte leads to

auto-detection of Unicode encoded scripts. This is fine until a script

contains null bytes following a call to __HALT_COMPILER() , when

execution results in ‘ a lot of ‘?’ garbage ‘. Effectively, this renders

anything using __HALT_COMPILER() (read: PHK or phar) incompatible

with --enable-zend-multibyte , with the only workaround being the

unacceptable one of turning off the detect_unicode flag.

François’ patch offered ‘ a small detection loop ‘ to check for a

sequence of four 0xff bytes; if found, Unicode detection is

switched off and the script considered non-Unicode. His idea was that

deliberately setting the switch would make generated archives compatible with

the configuration option.
--with-snapshot-template      Path to snapshot builder template dir
--enable-security-flags       Enable the compiler security flags
--enable-static-analyze       Enable the VC compiler static analyze
intel static analyze中使用static analyze 检查安全漏洞
http://software.intel.com/sites/products/documentation/doclib/stdxe/2013/composerxe/compiler/cpp-lin/GUID-9B795CE3-8341-47C1-83A9-614AB60110B3.htm
--with-aolserver              Build AOLserver support
--enable-apache               Build Apache 1.3.x version of PHP
--with-apache-includes        Where to find Apache 1.3 headers
--with-apache-libs            Where to find Apache 1.3 libraries
--enable-apache2filter        Build Apache 2.x filter
--enable-apache2-2filter      Build Apache 2.2.x filter
--enable-apache2handler       Build Apache 2.x handler
--enable-apache2-2handler     Build Apache 2.2.x handler
--with-apache-hooks           Build Apache 1.3.x (hooks) version of PHP
--disable-cgi                 Build CGI version of PHP
--disable-cli                 Build CLI version of PHP
--enable-crt-debug            Enable CRT memory dumps for debugging send to STDERR

检测内存泄漏的主要工具是调试器和 C 运行时库 (CRT) 调试堆函数。若要启用调试堆函数,请在程序中包括以下语句:

#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>

http://msdn.microsoft.com/zh-cn/library/e5ewb1h3(v=vs.80).aspx
--enable-cli-win32            Build console-less CLI version of PHP
--enable-embed                Embedded SAPI library
--enable-isapi                Build ISAPI version of PHP
--enable-nsapi                Build NSAPI for Netscape/iPlanet/SunONE
webservers
--with-nsapi-includes         Where to find NSAPI headers
--with-nsapi-libs             Where to find NSAPI libraries
--with-pi3web                 Pi3Web
--disable-bcmath              bc style precision math functions
--with-bz2                    BZip2
--disable-calendar            calendar conversion support
--disable-com-dotnet          COM and .Net support
--disable-ctype               ctype
--with-curl                   cURL support
--with-dba                    DBA support
Database (dbm-style) Abstraction Layer
--with-enchant                Enchant Support
Enchant spelling library
--without-ereg                POSIX extended regular expressions
--enable-fileinfo             fileinfo support
--disable-filter              Filter Support
是否使用flter扩展来处理安全过滤问题
http://blog.php-security.org/archives/64-Why-extfilter.html
--disable-ftp                 ftp support
--without-gd                  Bundled GD support
--without-t1lib               t1lib support
--with-gettext                gettext support
--with-gmp                    Include GNU MP support.
--disable-hash                enable hash support
--with-mhash                  mhash support
--without-iconv               iconv support
--with-imap                   IMAP Support
--with-interbase              InterBase support
--enable-intl                 Enable internationalization support
使用ICU库提供软件 Unicode 和 Globalization支持, http://site.icu-project.org/
--disable-json                JavaScript Object Serialization support
--with-ldap                   LDAP support
--enable-mbstring             multibyte string functions
--enable-mbregex              multibyte regex support
--disable-mbregex-backtrack   check multibyte regex backtrack
--with-mcrypt                 mcrypt support
--with-mssql                  mssql support
--with-dblib                  mssql support with freetds
--without-mysqlnd             Mysql Native Client Driver
--with-oci8                   OCI8 support
--with-oci8-11g               OCI8 support using Oracle 11g Instant C
--disable-odbc                ODBC support
--with-openssl                OpenSSL support
--with-pgsql                  PostgreSQL support
--with-pspell                 pspell/aspell (whatever it's called thi
month) support
--disable-session             session support
--enable-shmop                shmop support
--with-snmp                   SNMP support
--enable-sockets              SOCKETS support
--with-sqlite3                SQLite 3 support
--with-config-file-scan-dir   Dir to check for additional php ini fil
--with-sybase-ct              SYBASE_CT support
--with-tidy                   TIDY support
--disable-tokenizer           tokenizer support
--disable-zip                 ZIP support
--disable-zlib                ZLIB support
--without-libxml              LibXML support
--without-dom                 DOM support
--enable-exif                 exif
--with-mysql                  MySQL support
--with-mysqli                 MySQLi support
--enable-pdo                  Enable PHP Data Objects support
--with-pdo-dblib              freetds dblib (Sybase, MS-SQL) support
--with-pdo-mssql              Native MS-SQL support for PDO
--with-pdo-firebird           Firebird support for PDO
--with-pdo-mysql              MySQL support for PDO
--with-pdo-oci                Oracle OCI support for PDO
--with-pdo-odbc               ODBC support for PDO
--with-pdo-pgsql              PostgreSQL support for PDO
--with-pdo-sqlite             for pdo_sqlite support
--with-pdo-sqlite-external    for pdo_sqlite support from an external
--disable-phar                disable phar support
--enable-phar-native-ssl      enable phar with native OpenSSL support
--without-simplexml           Simple XML support
--enable-soap                 SOAP support
--with-sqlite                 SQLite support
--without-wddx                WDDX support
--without-xml                 XML support
--disable-xmlreader           XMLReader support
--with-xmlrpc                 XMLRPC-EPI support
--disable-xmlwriter           XMLWriter support
--with-xsl                    xsl support
--enable-com-dotnet=shared   windows 特有扩展支持,可以使用com和.net库
http://www.php.net/manual/en/refs.utilspec.windows.php
编译问题:
d:\phpdev\php53dev\vc9\x86\php-5.3.17\ext\calendar\jewish.c(324) : error C2001:
常量中有换行符
多行上面的错误,发现php bugs上面已经有提交了,也有人说通过editplus来处理字符集问题也不行,后来通过将linux下的UTF-8编码的内容复制过来就可以了,不过文件还是要转换为UTF-8来处理

编译PHP的windows版本相关推荐

  1. 6 redis 编译失败_Redis6 Windows 版本编译

    编译工具 Cygwin3 步骤 选择安装路径,这个是之cygwin命令窗口的路径.这个路径就是cygwin模拟linux环境的根路径/,再这个路径之下会有home/的文件夹,相当于windows环境中 ...

  2. 【我的渲染技术进阶之旅】如何编译Filament的windows版本程序?

    一.Filament简介 Filament 是一个基于物理的实时渲染引擎,适用于 Android.iOS.Windows.Linux.macOS 和 WebGL2.它被设计为在 Android 上尽可 ...

  3. ffmpeg windows版本交叉编译方法

    写在前面 FFmpeg是一个开源且跨平台的音视频解决方案,集采集.转码.流式化为一身,项目的libavcodec编解码模块和libavformat媒体格式模块,支持非常非常丰富的编解码格式和容器封装格 ...

  4. Caffe Windows版本的编译

    2019独角兽企业重金招聘Python工程师标准>>> 1:Caffe的主版本只支持Linux,所以要下载专门的Caffe Windows版本,网址为 https://github. ...

  5. 在windows下编译FFMPEG-最新2009版本

    转]在windows下编译FFMPEG-最新2009版本 2010-11-17 18:50 大家可以看到,此篇之前有很多个版本的"在windows下编译FFMPEG",那些都是我在 ...

  6. 开源终端上网行为管理服务器windows版本包的编译及运行环境搭建

    前面几篇文章主要介绍开源终端上网行为管理服务器的编译与部分代码解讯,这里主要介绍下这个开源服务器的搭建过程,分别从环境的要求,服务的启动与一些基本配置来说明 1.从https://github.com ...

  7. Windows中编译wireshark3.0以上版本指南

    Windows中编译wireshark3.0以上版本指南 一.摘要 在网上已有的wireshark编译的网页文档中,只有编译wireshark1.0和wireshark2.0相关版本的内容,对于已经发 ...

  8. WebRTC:如何编译Windows版本的WebRTC(M66)

    我主要做安卓上的WebRTC,然而为了读懂源码,不得不使用PC版本来调试源码.so... 环境: Windows 10,Visual Studio 2017(企业版),Python,depot_too ...

  9. xhprof在windows下面的安装和使用[上](windows版本)

    1.xhprof到底能干啥? xhprof是Facebook放出的轻量级调试工具.和Xdebug相比xhprof更加易用和可控.尤其是生成流程图和调试数据对比的功能很好很强大. 2.如何安装xhpro ...

最新文章

  1. MATLAB 数组运算
  2. RocketMQ削峰
  3. SQL------Hint
  4. java国际化——消息格式化+文本文件和字符集
  5. 苹果cmsv10精仿迅播影院2tu风格主题模板
  6. php中ajax方法的理解,基本的PHP和AJAX
  7. 20171227/20171027
  8. 《解决微信内置浏览器返回上一页强制刷新问题方法》
  9. php 有趣的php 封装,封装PHP常用的操作类
  10. HDU1408 盐水的故事【模拟+数学】
  11. HackingTeam重磅炸弹: 估值超1000万美金带有军火交易性质的木马病毒以及远控源码泄露
  12. 第十一课 Solidity语言编辑器REMIX指导大全
  13. 锁定计算机和睡眠有什么区别,电脑的睡眠和休眠选项有什么区别?怎么唤醒休眠的电脑?...
  14. 高通QCC5100系列蓝牙音频模块芯片
  15. 计算机怎么取消用户密码,怎么取消电脑开机密码界面
  16. 52 图初探 Linux 通用知识
  17. 十年期国债利率倒数与A股PE中位数走势
  18. Android图片压缩框架汇总分析
  19. 2022-2000-1978:世纪前后22年
  20. TFC 2017 腾讯Web前端大会 全场笔记

热门文章

  1. 好分数阅卷3.0_好分数阅卷3.0app
  2. 【计算机网络】-TCP的连接建立
  3. 2017年三月初大厂前端面试总结
  4. 原生分页查询原理步骤解析
  5. 计算机eq7怎么算标准差,精密坐标测量中小段圆弧的一种评价方法.pdf
  6. source命令的作用
  7. 中国煤矸石工业市场运行现状与十四五投资潜力分析报告2022版
  8. CVPR2022新作:P图不会,深度学习来帮忙,基于GAN逆映射的图像编辑(中)
  9. xshell启动报nssock2_nssock2.dll下载|
  10. cegui 汉字 处理