原文地址
http://www.opalvoip.org/wiki/index.php?n=Main.BuildingPTLib
Windows下编译PWLib
目录
1. 介绍
本文详细描述了如何使用VS.net 2003 和 VS.net 2005编译PTlib。对MSVC6的支持已经不再维护了,因为这个版本太旧了,而且在很多应用场景下都有很多bug。
2. 先决条件
需要有下面的准备:
注意,后面的没明白,原文是:
Note that you cannot use the VS.net 2003 available from Microsoft as building without the IDE is not supported. Visual C++ 2005 Expresss Edition is supported (follow the instructions for VS.net 2005)
3. 下载并且安装PTLib 源代码
下载并且解压PTLib源代码,在本文档中,含有Opal的目录表示为installdir/PTLIB
4. 打开解决方案文件
如果是VS.net 2003,使用ptlib.sln文件;
如果是VS.net 2005,使用 ptlib_2005.sln文件;
解决方案有下面一些工程:
5. 配置目录
在vs中选择 【工具】->【选项】打开【选项对话框】,按照下面的进行设置
*添加installdir/PTLIB/INCLUDE到 项目 包含目录中
*添加installdir/PTLIB/LIB到 项目 执行目录中
*添加installdir/PTLIB/LIB到 项目 库s目录中
6. 安装 GNU bison
编译PTLib时需要工具GNU Bison工具,GNU flex对于大多数用户来说是不需要的,但是当因为修改支持Opal的ASN文件而重新编译“asnparser”程序时就需要了。这两个工具我们都提供了,因为同时提供要比单独提供简单。
预编译的工具版本在这里提供,按下面的步骤安装
重要提示:不要试图将bison和flex安装到C:/TOOLS以外的目录,它可以工作,但是那样会很麻烦,而且不值得(译者注:应该是与configure的搜索有关)
The PTLib build process will automatically detect many packages that are installed on the host system. Before starting the build process, select and install the packages from the list below that are needed:
See the Microsoft information page for more information. Compiling Microsoft Speech API with Visual C++ 2005 requires some modifications to the "SpHelper.h" SAPI include file. See this thread in the Microsoft forum on this subject.
VS.net includes support for the DNS resolver, and this will be detected automatically by the PTLib configure process
8. Build the PTLIB Static project
Build the PTLib Static project to create a static code library containing all of the PTLib code. In Release mode, this will build the ptlibs.lib file. In Debug mode, this will build the ptlibsd.lib file.
The compiler output will be similar to the belows (it will vary depending on options or build environment).
Note that the first step of the build is the execution of the configure program which searches for optional components that may be installed on the host system.
IMPORTANT TIP: If configure finds options in directories not belonging to other compilers, such as Cygwin, MSys, MSVC 6, or the wrong version of VS.net, then please read section 10 "Tailoring the configure search path" below on how to tailor the configure search path
------ Build started: Project: PTLib, Configuration: Release Win32 ------
Configuring Build Options
Located Open LDAP at D:/openldap/
Located Expat XML at D:/expat/
Located Speech API at D:/Program Files/Microsoft Speech SDK 5.1/
Searching C:/
Searching D:/
Located Cyrus SASL at D:/cyrus-sasl-2.1.12/
Located Open SSL at D:/openssl-0.9.7/
Located DNS Resolver at D:/Program Files/Microsoft Visual Studio .NET 2003/Vc7/PlatformSDK/
Located IPv6 Support at D:/Program Files/Microsoft Visual Studio .NET 2003/Vc7/PlatformSDK/Include/
Located QoS Support at D:/Program Files/Microsoft Visual Studio .NET 2003/Vc7/PlatformSDK/Include/
Searching E:/
Byte Order set to PLITTLE_ENDIAN
Semaphore Support enabled
DNS Resolver enabled
Cyrus SASL enabled
Open LDAP enabled
Open SSL enabled
Expat XML enabled
Speech API enabled
IPv6 Support enabled
QoS Support enabled
Simple DirectMedia Layer disabled
Memory check switch read enabled
Configuration completed.
Performing Custom Build Step
../common/getdate.y contains 8 shift/reduce conflicts and 18 reduce/reduce conflicts.
Compiling...
assert.cxx
Compiling...
notifier_ext.cxx
mail.cxx
...lines deleted...
Generating Code...
getdate_tab.c
Creating library...
Build log was saved at "file://d:/ptlib/Lib/Debug/BuildLog.htm"
Console - 0 error(s), 1 warning(s)
---------------------- Done ----------------------
Build: 1 succeeded, 0 failed, 0 skipped
9. Build the PTLIB DLL project
The PTLIB Static project must be built before building PTLib DLL.
Build the PTLib DLL project to create a DLL code library containing all of the PTLib code. In Release mode, this will build the ptlib.dll file. In Debug mode, this will build the ptlibd.dll file.
The compiler output will be similar to the belows (it will vary depending on options or build environment). Note that MERGESYM will be automatically built the first time you build PTLib DLL, which may require also building the "Release" version of PTLib if that was not done previously.
------ Build started: Project: MergeSym, Configuration: Release Win32 ------
Compiling...
MergeSym.cxx
Linking...
Copying symbol merge utility to ptlib/lib directory.
Build log was saved at "file://d:/ptlib/tools/MergeSym/Release/BuildLog.htm"
MergeSym - 0 error(s), 0 warning(s)
------ Build started: Project: PTLib, Configuration: Release Win32 ------
Performing Custom Build Step
MergeSym version 1.4.0 on Windows 2000 by Equivalence
No changes to symbols.
Compiling...
dllmain.cxx
Compiling resources...
Linking...
Creating library ./../../../Lib/PTLib.lib and object ./../../../Lib/PTLib.exp
Extracting debug symbols
REBASE: Total Size of mapping 0x00000000000d0000
REBASE: Range 0x0000000010000000 -0x00000000100d0000
Build log was saved at "file://d:/ptlib/Lib/Release/BuildLog.htm"
PTLib - 0 error(s), 0 warning(s)
---------------------- Done ----------------------
Build: 3 succeeded, 0 failed, 0 skipped
10. 裁减配置搜索路径
有时候,configure会识别安装包的位置失误(译者注:有多个编译器,都有相关的库,会首先使用先查到的)导致编译错误。常见问题是使用了Cygwin头文件,或者使用了错误版本的VS.net。
这个问题可以通过设置不被搜查的路径的环境变量来解决。
Name |
Sample value |
VSNET_PWLIB_CONFIGURE_EXCLUDE_DIRS |
C:/Program Files/Microsoft Visual Studio |
VSNET2005_PWLIB_CONFIGURE_EXCLUDE_DIRS |
D:/Program Files/Microsoft Visual Studio .NET 2003 |