編譯STLport
windows:
使用vs9以上版本編譯,需要修改代碼_cstdlib.h(158),增加對新版本的支援:
#if !defined(_STLP_MSVC) || (_STLP_MSVC < 1700)
inline _STLP_LONG_LONG abs(_STLP_LONG_LONG __x) { return __x < 0? -__x : __x; }
#endif
使用vs指令行工具進入控制台
configure.bat msvc9
cd build/lib
nmake clean install
linux:
cd stlport/build/lib
make -f gcc.mak
make -f gcc.mak install
編譯ProtoBuf
在http://code.google.com/p/protobuf/ 可以下載下傳到 Protocol Buffers 最新版。
在下載下傳的 Protocol Buffers 中找到 README.txt,此檔案包含了關于各個平台安裝(編譯)Protocol Buffers 的資訊。
windows:
打開 vsprojects 目錄下的 protobuf.sln 檔案,編譯整個工程(若需要編譯 64 位版本,在 MSVC 中增加相應的Solution Platform)
直接運作生成的 tests.exe 和 lite-test.exe 檢查所有的測試是否通過
運作extract_includes.bat 可以抽取頭檔案到一個 include 目錄下
使用STLport編譯 Protocol Buffers 會出現編譯問題,需要修改一下 vcproject/config.h 檔案:
#if _MSC_VER < 1310 || _MSC_VER >= 1600
#define HASH_NAMESPACE std
#else
#define HASH_NAMESPACE stdext
#endif
修改為:
// 增加對 STLport 命名空間的支援
#if _MSC_VER < 1310 || _MSC_VER >= 1600 || defined(_STLPORT_VERSION)
#define HASH_NAMESPACE std
#else
#define HASH_NAMESPACE stdext
#endif
// 為 STLport 定義 hash_map 和 hast_set 類名
#if defined(_STLPORT_VERSION)
#define HASH_MAP_CLASS hash_map
#define HASH_SET_CLASS hash_set
#endif
linux:
./autogen.sh
./configure CXXFLAGS="${CXXFLAGS} -I/home/li9chuan/STLport-5.2.1/stlport -lstlport"
make
make check
make install clean
config.h中hashmap的配置由 m4/stl_hash.m4生成。
由于 stlport 中的 template <class _Key> struct hash { }; 不在std::tr1中,自動生成的config.h使用unordered_map 在編譯時會找不到這個定義。
在執行make之前,configure同級目錄,修改config.h如下内容:
/* the name of <hash_map> */
#define HASH_MAP_CLASS hash_map
/* the location of <unordered_map> or <hash_map> */
#define HASH_MAP_H <hash_map>
/* the namespace of hash_map/hash_set */
#define HASH_NAMESPACE std
/* the name of <hash_set> */
#define HASH_SET_CLASS hash_set
/* the location of <unordered_set> or <hash_set> */
#define HASH_SET_H <hash_set>
編譯錯誤(g++ (Debian 4.4.7-2) 4.4.7):
protobuf/compiler/command_line_interface.cc(1562)
for (set<FieldRange>::iterator i = ranges.begin();
修改為:
for (set<FieldRange>::const_iterator i = ranges.begin();