1.下载STLPort。我下载的是STLport-5.2.1
2.把下载的stlport压缩包解压,我假设解压到C:/ STLport-5.2.1
3, Configuring STLport
在console窗口中进入C:/ STLport-5.2.1,运行congfigure –help,你会看到一些可用的编译选项。例如:使用winxp以上的操作系统在vc9环境下的命令是这样的:
C:/STLport-5.2.1>configure msvc9 -p winxp
如果正确会出现
STLport Configuration Tool for Windows
Setting compiler: Microsoft Visual C++ 2008
Setting platform: Windows XP
Done configuring STLport.
Go to build/lib folder and type "nmake clean install" to build and
install STLport to the "lib" and "bin" folders.
Go to build/test/unit folder and type nmake clean install to
build unit tests and install them in bin folder.
4. Building STLport
(1) 设置环境变量,使得环境变量PATH中包含C:/Program Files/Microsoft Visual Studio 9.0/VC/bin
(2) 进命令行控制台, 运行 C:/Program Files/Microsoft Visual Studio 9.0/VC中的vcvarsall.bat.如果正确会出现set environment for using Microsoft Visual Studio 2008 x86 tools.(所用机器不同可能不是x86) (C:/ STLport-5.2.1/lib目前还不存在,但不用着急,编译完stlport就有了)
(3) 再进入 C:/ STLport-5.2.1/ build/lib目录运行
nmake /fmsvc.mak clean install
如果正确会出现很长一段编译,请耐心等待。成功后 C:/ STLport-5.2.1目录下会增加两个目录(bin和 lib)
(4)把bin目录里的 stlport.5.2.dll, stlportd.5.2.dll, stlportstld.5.2.dll 复制到系统path的目录(C:/Program Files/Microsoft Visual Studio 9.0/VC/bin)里去。
5.配置vc
进入VC,在工具 选项 项目和解决方案 vc++目录中
选择包含文件,加入C:/STLport-5.2.1/stlport,并调到最前面
选择库文件,加入C:/STLport-5.2.1/lib,并调到最前面
编译工程,呵呵,应该通过了吧。同样的,为了验证我们用的是stlport的STL库,把鼠标放到程序中vector和push_back上,右键到其定义处(goto the Definition of ...),在弹出的窗口,选中一个进入定义文件,可以看出引用的是C:/ STLport-5.2.1/stlport/stl/_vector.h了。
至此,stlport 已经完全编译好了。Enjoy it !