天天看點

vs2012 使用STLport-5.2.1

下載下傳位址: http://sourceforge.net/projects/stlport/

  下載下傳後解壓,假設目錄為:D:\STLport,接下來就該編譯它了:

1.在開始菜單中找到VC 指令行工具,接下來切換到D:\STLport\STLport-5.2.1目錄。

2.可以運作configure –help看看編譯選項,用MSVC編譯器編譯的話,輸入以下指令:

configure msvc9(configure msvc11 會顯示 Unknown compiler: msvc10, msvc9即可)

3.輸入

cd build

cd lib

4.輸入

nmak clean install

(在第二步的時候會有提示讓你輸入安裝指令)

如果不出錯,稍等幾分鐘就OK了。

假若出現如下錯誤:

D:\STLport\STLport-5.2.1\stlport\stl/_cstdlib.h( 158) : error C2084: function  ' __int64 abs(__int64) '  already has a body

C:\Program Files\Microsoft Visual Studio  10.0\VC\INCLUDE\../include/stdlib.h( 471) : see previous definition of  ' abs '

NMAKE : fatal error U1077:  ' "C:\Program Files\Microsoft Visual Studio 10.0\VC\BIN\cl.EXE" ' :  return code  ' 0x2 '

用vs2010打開D:\STLport\STLport-5.2.1目錄下的_cstdlib.h檔案(可以搜尋到),找到158行:
158 inline _STLP_LONG_LONG abs(_STLP_LONG_LONG __x) { return __x < 0 ? -__x : __x; }      
将代碼修改為:

 #if !defined(_STLP_MSVC) || (_STLP_MSVC < 1600)

 inline _STLP_LONG_LONG abs(_STLP_LONG_LONG __x) { return __x < 0 ? -__x : __x; }

#endif

這樣儲存并重新編譯安裝即可。

使用 STLport

      使用STLport除了向項目添加 STLport 的頭檔案目錄和 Lib 目錄以外還有如下宏定義配合使用。
1 #define _STLP_USE_STATIC_LIB    // 使用 STLport 靜态庫   
2 #define _STLP_USE_DYNAMIC_LIB   // 使用 STLport 動态庫 
3 #define _STLP_DEBUG             // STLport 啟用 Debug 模式下的檢查功能   
4 #define _STLP_USE_BOOST_SUPPORT // STLport 與 Boost 庫配合使用       

繼續閱讀