#if !defined(_STLP_MSVC) || (_STLP_MSVC < 1700) inline _STLP_LONG_LONG abs(_STLP_LONG_LONG __x) { return __x < 0? -__x : __x; } #endif
configure.bat msvc9 cd build/lib nmake clean install
cd stlport/build/lib make -f gcc.mak make -f gcc.mak install
直接运行生成的 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>
for (set<FieldRange>::iterator i = ranges.begin();修改为:
for (set<FieldRange>::const_iterator i = ranges.begin();