1. 程式人生 > >在windows下編譯 stlport 5.1.4

在windows下編譯 stlport 5.1.4

2007-12-08

#

周海漢 /文 轉載註明出處

stlport是對C++標準模板庫的一個實現,遵循INTERNATIONAL STANDARD ISO/IEC 14882:1998(E) 和最新的ISO/IEC 14882:2003(E)標準。它的一個好處,就是提供了跨平臺和跨編譯器的實現。另外它還有一個易於使用的“安全模式”可以檢測容器和迭代器的不正確 用法。對於通用的功能也進行了優化。它的原始碼比微軟的實現也易於閱讀。

但是stlport沒有提供vc6和vc8的編譯專案檔案,而是提供了相應的各編譯器的make file。這給windows下編譯增加了一定困難。必須在命令列下用nmake來進行編譯,以生成相應的lib檔案。編譯過程可以參考 doc/README.msvc這個檔案。這裡以vc6編譯為例。

首先,用命令列進到stlport的解壓目錄的buildlib目錄,執行:

configure -c msvc6

執行完畢,會提示用nmake /fmsvc.mak來編譯。執行:

E:cvsvodthirdpartySTLport-5.1.4buildlib>nmake /fmsvc.mak Microsoft (R) Program Maintenance Utility   Version 7.00.8882 Copyright (C) Microsoft Corp 1988-2000. All rights reserved. cl /nologo /W4 /GX /GR /Zm800  /MD /Zi /O2  /DWIN32 /D_WINDOWS /DNDEBUG /I../../stlport  /c /Foobjvc6shareddll_main.o /Fdobjvc6sharedstlport.5.1. pdb ../../srcdll_main.cpp dll_main.cpp D:Program FilesMicrosoft Platform SDK for Windows Server 2003 R2Include.win base.h(1576) : error C2733: second C linkage of overloaded function 'Interlocked Increment' not allowed D:Program FilesMicrosoft Platform SDK for Windows Server 2003 R2Inclu de.winbase.h(1574) : see declaration of 'InterlockedIncrement' D:Program FilesMicrosoft Platform SDK for Windows Server 2003 R2Include.win base.h(1583) : error C2733: second C linkage of overloaded function 'Interlocked Decrement' not allowed D:Program FilesMicrosoft Platform SDK for Windows Server 2003 R2Inclu de.winbase.h(1581) : see declaration of 'InterlockedDecrement' D:Program FilesMicrosoft Platform SDK for Windows Server 2003 R2Include.win base.h(1591) : error C2733: second C linkage of overloaded function 'Interlocked Exchange' not allowed D:Program FilesMicrosoft Platform SDK for Windows Server 2003 R2Inclu de.winbase.h(1588) : see declaration of 'InterlockedExchange' NMAKE : fatal error U1077: 'cl' : return code '0x2' Stop.

這是因為安裝了plaform SDK引起的錯誤。這需要修改原始碼了。找到stlportstlconfiguser_config.h,開啟,找到

#define _STLP_NEW_PLATFORM_SDK 1,將其註釋去掉。修改後如下:

/*// * boris : this setting is here as we cannot detect precense of new Platform SDK automatically * If you are using new PSDK with VC++ 6.0 or lower, * please define this to get correct prototypes for InterlockedXXX functions */

#define _STLP_NEW_PLATFORM_SDK 1

再執行nmake /fmsvc.mak,就會通過了。 接著執行nmake /fmsvc.mak install,會將相應的lib檔案拷貝到bin目錄。

如果找不到nmake,則需要安裝環境變數。找到VC6安裝目錄,用命令列進入其VC98/Bin,執行vcvars32.bat,即可得到相應環 境變數。

如非註明轉載, 均為原創. 本站遵循知識共享CC協議,轉載請註明來源