天天看點

Win7下VS2010使用STLPort .

Win7下VS2010使用STLPort ———— 更新于2012年8月24日 星期五 http://blog.csdn.net/shunqiziranhao007/article/details/7905435 ———— STLport的下載下傳位址 http://sourceforge.net/projects/stlport/   下載下傳後,解壓出檔案。我的目錄是 D:\STLport-5.2.1 。   右鍵計算機,屬性,進階系統設定,環境,系統變量,編輯Path變量,添加;C:\Program Files\Microsoft Visual Studio 10.0\VC\bin。(我的路徑是這樣,分号是分隔符),确定。。   然後在 C:\Program Files\Microsoft Visual Studio 10.0\VC\bin 目錄,編輯 vcvars32.bat 。   找到下面的一段,主要是添加STLport的include和lib路徑,我的分别是 D:\STLport-5.2.1\stlport和D:\STLport-5.2.1\build\lib,注意分号,它是分隔符。   @rem INCLUDE @rem ------- @if exist "%VCINSTALLDIR%ATLMFC\INCLUDE" set INCLUDE=%VCINSTALLDIR%ATLMFC\INCLUDE;%INCLUDE%;D:\STLport-5.2.1\stlport @if exist "%VCINSTALLDIR%INCLUDE" set INCLUDE=%VCINSTALLDIR%INCLUDE;%INCLUDE%   @rem LIB @rem --- @if exist "%VCINSTALLDIR%ATLMFC\LIB" set LIB=%VCINSTALLDIR%ATLMFC\LIB;%LIB%;D:\STLport-5.2.1\build\lib @if exist "%VCINSTALLDIR%LIB" set LIB=%VCINSTALLDIR%LIB;%LIB%     儲存之後,輕按兩下 vcvars32.bat ,使我們的設定生效。   在 C:\Program Files\Microsoft Visual Studio 10.0\VC 目錄下,運作 vcvarsall.bat 。   在 D:\STLport-5.2.1\stlport\stl 目錄,編輯 _cstdlib.h。 将第158行的   inline _STLP_LONG_LONG  abs(_STLP_LONG_LONG __x) { return __x < 0 ? -__x : __x; }   這一行改為如下三行。(就是多了個if判斷。)   #if !defined(_STLP_MSVC) || (_STLP_MSVC < 1600) inline _STLP_LONG_LONG abs(_STLP_LONG_LONG __x) { return __x < 0 ? -__x : __x; } #endif   儲存。   打開開始菜單的Microsoft Visual Studio 2010下的Visual Studio Tools中Visual Studio Command Prompt(2010)。   切換到STLport的目錄下 cd D:\STLport-5.2.1 d: 進行配置,可以通過 configure --help檢視支援哪些配置。 configure msvc9 切換到lib目錄 cd build/lib 然後是 nmake /f msvc.mak clean install   我測試的效果如下:   Setting environment for using Microsoft Visual Studio 2010 x86 tools   C:\Program Files\Microsoft Visual Studio 10.0\VC>cd D:\STLport-5.2.1   C:\Program Files\Microsoft Visual Studio 10.0\VC>d:   D:\STLport-5.2.1>configure msvc9 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.     D:\STLport-5.2.1>cd build/lib   D:\STLport-5.2.1\build\lib>nmake /f msvc.mak clean install     ———— 等了幾分鐘就安裝好了。   在D:\STLport-5.2.1目錄多了幾個檔案夾,如bin和lib等。   把 D:\STLport-5.2.1\bin下 stlport.5.2.dll,stlportd.5.2.dll,stlportstld.5.2.dll,複制到 C:\Program Files\Microsoft Visual Studio 10.0\VC\bin 目錄下,這樣vc就能找到它了。   設定vc工程的include和lib目錄了。 VS2010菜單,View,Property Manager,Debug|Win32,輕按兩下Microsoft.Cpp.Win32.user,Common Properties,VC++ directories。 在 Include Directories 下添加 D:\STLport-5.2.1\stlport 。 在 Library Directories 下添加 D:\STLport-5.2.1\lib 。   确定,通過這樣的設定,以後建立的工程的VC++ Directories都有這些東西,就不用那麼麻煩每個工程都進行設定了。   測試程式。

  1. #include <iostream>   
  2. #include <rope>   
  3. using namespace std;  
  4. int main()  
  5. {  
  6.     // crope是用來存儲char字元的容器   
  7.     crope crope1("Hello,");  
  8.     crope crope2("STLport!");  
  9.     cout << crope1 + crope2 << endl;  
  10.     system("pause");  
  11.     return 0;  
  12. }  

繼續閱讀