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 !