http://www.stlport.org,具体内容就不详细描述了!
A、在Windows中安装
1.编辑VC安装目录下VC98的VC98\bin中运行vcvars32.bat,在最后添加如下三行:
set STLPATH=E:\STLport-5.2.1
set INCLUDE=%STLPATH%\stlport;%INCLUDE%
set LIB=%STLPATH%\lib;%LIB%。
2.把vcvars32.bat另存为vcvars32_stl.bat
3.运行vcvars32_stl.bat。
4.到%STLPort%\build\lib\下,在命令提示符下执行configure.bat -c msvc6。
5.执行nmake /fmsvc.mak install开始编译。
6.编译结束后,将bin\目录下的三个*.dll文件拷贝到windows\system32\目录下。
7.设置%STLPort%目录下的\include\和\lib\目录到VC的默认include和lib路径之中,要把%STLPort%放在第一行,以保证先使用STLPort。
最后注意,STLPort在控制台程序中使用时要更改运行时库为多线程库,否侧编译通不过。
B、在linux-openSUSE11.0安装
1.把STLport-5.2.1.rar解压到/home/STLport-5.2.1目录中。
2.#cd /home/STLport-5.2.1/build/lib
3.#make -f gcc.mak depend
4.#make -f gcc.mak install
5.编写测试程序
// testSTLPort521.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <hash_map>
#include <string>
using namespace std;
int main()
{
hash_map<int, string> mymap;
mymap[0x2011] = "liuxuezong";
mymap[0x7c00] = "STLport";
mymap[0x9000] = "hello hash_map!";
hash_map<int, string>::iterator iter = mymap.find(0x9000);
if (iter != mymap.end())
{
cout << iter->second << endl;
}
return 0;
}
teststlport521程序Makefile文件编写
PRJNAME= teststlport521
PRJOUT = /FEPDebug
include $(FEPHOME)/code/include/makefile_linux
####### Files
SRCDIR =../src
SOURCES = stdafx.cpp \
testSTLPort521.cpp
OBJECTS = $(OBJDIR)/stdafx.o \
$(OBJDIR)/testSTLPort521.o
FEPLIB = -lstlport
STLPATH = -I/usr/local/include/stlport
INCPATH += $(STLPATH)
OUTBIN = $(BINDIR)/$(PRJNAME)
####### Build rules
all: obj_dir $(OUTBIN)
obj_dir:
@$(CHK_DIR_EXISTS) $(OBJDIR) || $(MKDIR) $(OBJDIR)
$(OUTBIN): $(OBJECTS)
$(CXX) -o $@ $(OBJECTS) $(FEPLIB)
####### Include file dependencies
depend:
@(mkdepend -p$(OBJDIR)/ -o.o $(INCPATH) $(SOURCES))>/dev/null 2>&1
@rm -f makefile.bak
clean:
rm -f $(OBJECTS)
rm -f $(OUTBIN)
####### Compile
$(OBJDIR)/stdafx.o: $(SRCDIR)/stdafx.cpp
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $?
$(OBJDIR)/testSTLPort521.o: $(SRCDIR)/testSTLPort521.cpp
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $?
# DO NOT DELETE THIS LINE -- make depend depends on it.
编译后运行测试
# ./teststlport521
hello hash_map!