Design&Art

C++博客 首页 新随笔 联系 聚合 管理
  26 Posts :: 0 Stories :: 38 Comments :: 0 Trackbacks
为了使用hash_map,今天下载了STLport,在VC6下编译成功。

1. STLport下载:http://www.stlport.org/
      我下载的是最新版  02.25.07: STLport 5.1.2 released

2. STLport编译:
      我的STLport目录是:D:\STLport-5.1.2
      先设置一下VC6下的环境变量:C:\Program Files\Microsoft Visual Studio\VC98\Bin\VCVARS32.BAT
     把D:\STLport-5.1.2\stlport;加入Include路径中;把D:\STLport-5.1.2\lib;加入Lib路径中
      在命令行窗口下:
      运行VCVARS32.BAT,然后
      cd D:\STLport-5.1.2\build\lib
      configure -c msvc6
      nmake /fmsvc.mak install
      编译全部用的默认选项,因此编译出来的是多线程静态链接库。库文件被拷贝到D:\STLport-5.1.2\lib

3. 在VC6中使用STLport:
      Tools->Options...->Directories中
      include设置中添加目录:D:\STLport-5.1.2\stlport
      library设置中添加目录:D:\STLport-5.1.2\lib
      Project->Settings...->C/C++中
      Category选择Code Generation,然后在use run-time library中选择Debug Multithreaded。(如果是release版本,选择Multithreaded;如果想用动态链接,则要先编译动态链接版本的STLport,再在这儿选择相应的DLL)

4. hash_map的例子:
#include <iostream>
#include 
<hash_map>
#include 
<string>

using namespace std;

int main()
{
    hash_map
<intstring> mymap;
    mymap[
2008]="VC6";
    mymap[
999999]="STLport";
    mymap[
123456]="hello hash_map!";
    hash_map
<intstring>::iterator iter = mymap.find(123456);
    
if(iter != mymap.end())
    
{
        cout
<<iter->second<<endl;
    }

    
return 0;
}

posted on 2007-04-16 14:22 安帛伟 阅读(8331) 评论(21)  编辑 收藏 引用 所属分类: STL

Feedback

# re: VC6下使用STLPort 2007-05-20 21:12 risefei
若问:设置一下VC6下的环境变量:C:\Program Files\Microsoft Visual Studio\VC98\Bin\VCVARS32.BAT
怎么设置?  回复  更多评论
  

# re: VC6下使用STLPort 2007-05-20 23:24 abware
@risefei
用记事本打开VCVARS32.BAT
查找set INCLUDE=和set LIB=
把D:\STLport-5.1.2\stlport;加入Include路径中;把D:\STLport-5.1.2\lib;加入Lib路径中
示例如下:
set INCLUDE=D:\STLport-5.1.3\stlport;%MSVCDir%\ATL\INCLUDE;%MSVCDir%\INCLUDE;%MSVCDir%\MFC\INCLUDE;%INCLUDE%
set LIB=D:\STLport-5.1.3\lib;%MSVCDir%\LIB;%MSVCDir%\MFC\LIB;%LIB%
  回复  更多评论
  

# re: VC6下使用STLPort[未登录] 2007-06-12 16:45 hh
好象没有你下的饿哪个版本只有STLport-4.6.2.tar.gz这个里面没有lib文件夹 也没有*.lib文件! xp下的cmd不能认识make nmake 命令啊!怎么办?  回复  更多评论
  

# re: VC6下使用STLPort[未登录] 2007-06-12 22:11 hh
我按照以上弄好了 不过编译文件时 错误更多了!例如:
error C2039: 'ostream' : is not a member of 'stlp_std'
error C2061: syntax error : identifier 'ostream' 等等! 是什么问题 请指教!3Q  回复  更多评论
  

# re: VC6下使用STLPort[未登录] 2007-06-13 10:20 hh
针对你上面写的那个程序也有问题 LIKE是有9个错误 !是我那里没有设置正确 ?
其中的一个错误:unresolved external symbol "class stlpmtx_std::basic_ostream<char,class stlpmtx_std::char_traits<char> > stlpmtx_std::cout" (?cout@stlpmtx_std@@3V?$basic_ostream@DV?$char_traits@D@stlpmtx_std@@@1@A)  回复  更多评论
  

# re: VC6下使用STLPort报这个错误是怎么回事啊 2007-06-22 15:37 lee
LINK : fatal error LNK1104: cannot open file "stlport_static_stld50.lib"
Error executing link.exe.  回复  更多评论
  

# re: VC6下使用STLPort 2007-06-26 20:40 abware
看看你编译出来的库文件在哪,该路径是否加到了VC6的环境变量配置文件VCVARS32.BAT中
@lee
  回复  更多评论
  

# re: VC6下使用STLPort 2007-06-26 20:42 abware
@hh
你仔细按照步骤来,特别注意第3步里use run-time library中选择的版本要和你编译出来的版本一致。  回复  更多评论
  

# re: VC6下使用STLPort 2008-01-09 13:10 wsfyc
看了这篇文章,LINK问题终于解决了.按照步骤可定 成功。我的是STLPORT5-1-4  回复  更多评论
  

# re: VC6下使用STLPort[未登录] 2008-01-10 20:31 Eric
@hh
请问您这个问题是怎么解决的?,我也有这个问题@@

谢谢:)  回复  更多评论
  

# re: VC6下使用STLPort 2008-04-10 02:27 人渣
好东西啊,谢谢您了  回复  更多评论
  

# re: VC6下使用STLPort 2008-05-12 00:31 zyz
@abware
这个怎么提示 不是内部指令呢?  回复  更多评论
  

# re: VC6下使用STLPort 2008-10-14 21:42 smallping
我用的是录制动画程序Camstudio-2.0-src,按照上面的配置做好了,但编译之后错误更多,如下:
ompiling...
FFont.cpp
D:\Camstudio-2[1].0-src\vscap20s\Producer\swfsource\FFont.h(22) : error C2039: 'ostream' : is not a member of 'stlp_std'
D:\Camstudio-2[1].0-src\vscap20s\Producer\swfsource\FFont.h(22) : error C2061: syntax error : identifier 'ostream'
D:\Camstudio-2[1].0-src\vscap20s\Producer\swfsource\FFont.h(22) : error C2039: 'istream' : is not a member of 'stlp_std'
D:\Camstudio-2[1].0-src\vscap20s\Producer\swfsource\FFont.h(22) : error C2061: syntax error : identifier 'istream'
D:\Camstudio-2[1].0-src\vscap20s\Producer\swfsource\FFont.h(28) : error C2039: 'istream' : is not a member of 'stlp_std'
D:\Camstudio-2[1].0-src\vscap20s\Producer\swfsource\FFont.h(28) : error C2143: syntax error : missing ';' before '&'
D:\Camstudio-2[1].0-src\vscap20s\Producer\swfsource\FFont.h(28) : error C2433: 'istream' : 'friend' not permitted on data declarations
D:\Camstudio-2[1].0-src\vscap20s\Producer\swfsource\FFont.h(28) : error C2501: 'istream' : missing storage-class or type specifiers

不知是什么原因,怎么也搞不明白,急急急!!!
那位好心的大哥知道请告诉我。
邮箱:smallping_hit@yahoo.com.cn  回复  更多评论
  

# re: VC6下使用STLPort 2008-10-29 17:56 guobosheng
在执行 nmake /fmsvc.mak install 命令时出错:'nmake' 不是内
或批处理文件。

这个问题怎么解决的?急!谢谢帮忙!  回复  更多评论
  

# re: VC6下使用STLPort 2008-10-29 18:00 guobosheng
@hh

你是否也有 'nmake' 不是内部或外部命令,也不是可运行的程序或批处理文件。这个问题?你是怎么解决的?  回复  更多评论
  

# re: VC6下使用STLPort 2008-10-30 10:07 guobosheng
@guobosheng
关于“'nmake' 不是内部或外部命令,也不是可运行的程序或批处理文件。”问题的解决办法:

在“我的电脑--属性--高级--环境变量”中, 添加如下变量:
  INCLUDE
  D:\Program Files\Microsoft Visual Studio\VC98\Include
  LIB
  D:\Program Files\Microsoft Visual Studio\VC98\Lib
  X:\Program Files\Microsoft Visual Studio\Common\MSDev98\Bin;X:\Program Files\Microsoft Visual Studio\VC98\Bin
  X表示安装盘符,注意这里是两个路径,因为cl.exe要用到MSDev98\Bin目录下的MSPDB60.DLL。
  如果已经存在这些变量,则把以上值分别加在对应的变量值的后面,注意在添加前用分号隔开。  回复  更多评论
  

# re: VC6下使用STLPort 2008-10-30 10:27 guobosheng
编译STLPort后出现102个错误!~~谁能救救我?
错误信息:

--------------------Configuration: stl - Win32 Debug--------------------
Compiling...
stl.cpp
c:\program files\microsoft visual studio\vc98\include\string(17) : error C2143: syntax error : missing ';' before '<'
c:\program files\microsoft visual studio\vc98\include\string(17) : error C2433: 'basic_string' : 'inline' not permitted on data declarations
c:\program files\microsoft visual studio\vc98\include\string(17) : error C2501: 'basic_string' : missing storage-class or type specifiers
c:\program files\microsoft visual studio\vc98\include\string(17) : error C2059: syntax error : ';'
c:\program files\microsoft visual studio\vc98\include\string(17) : error C2059: syntax error : '<'
c:\program files\microsoft visual studio\vc98\include\string(24) : error C2143: syntax error : missing ';' before '{'
c:\program files\microsoft visual studio\vc98\include\string(24) : error C2447: missing function header (old-style formal list?)
c:\program files\microsoft visual studio\vc98\include\string(25) : error C2954: template definitions cannot nest
c:\program files\microsoft visual studio\vc98\include\string(26) : error C2143: syntax error : missing ';' before '<'
c:\program files\microsoft visual studio\vc98\include\string(26) : error C2433: 'basic_string' : 'inline' not permitted on data declarations
c:\program files\microsoft visual studio\vc98\include\string(26) : error C2501: 'basic_string' : missing storage-class or type specifiers
c:\program files\microsoft visual studio\vc98\include\string(26) : error C2086: 'basic_string' : redefinition
c:\program files\microsoft visual studio\vc98\include\string(26) : error C2059: syntax error : ';'
c:\program files\microsoft visual studio\vc98\include\string(26) : error C2059: syntax error : '<'
c:\program files\microsoft visual studio\vc98\include\string(33) : error C2143: syntax error : missing ';' before '{'
c:\program files\microsoft visual studio\vc98\include\string(33) : error C2447: missing function header (old-style formal list?)
c:\program files\microsoft visual studio\vc98\include\string(34) : error C2954: template definitions cannot nest
c:\program files\microsoft visual studio\vc98\include\string(35) : error C2143: syntax error : missing ';' before '<'
c:\program files\microsoft visual studio\vc98\include\string(35) : error C2433: 'basic_string' : 'inline' not permitted on data declarations
c:\program files\microsoft visual studio\vc98\include\string(35) : error C2501: 'basic_string' : missing storage-class or type specifiers
c:\program files\microsoft visual studio\vc98\include\string(35) : error C2086: 'basic_string' : redefinition
c:\program files\microsoft visual studio\vc98\include\string(35) : error C2059: syntax error : ';'
c:\program files\microsoft visual studio\vc98\include\string(35) : error C2059: syntax error : '<'
c:\program files\microsoft visual studio\vc98\include\string(41) : error C2143: syntax error : missing ';' before '{'
c:\program files\microsoft visual studio\vc98\include\string(41) : error C2447: missing function header (old-style formal list?)
c:\program files\microsoft visual studio\vc98\include\string(42) : error C2954: template definitions cannot nest
c:\program files\microsoft visual studio\vc98\include\string(44) : error C2143: syntax error : missing ',' before '<'
c:\program files\microsoft visual studio\vc98\include\string(44) : error C2059: syntax error : '<'
c:\program files\microsoft visual studio\vc98\include\string(45) : error C2803: 'operator ==' must have at least one formal parameter of class type
c:\program files\microsoft visual studio\vc98\include\string(46) : error C2954: template definitions cannot nest
c:\program files\microsoft visual studio\vc98\include\string(47) : error C2143: syntax error : missing ',' before '<'
c:\program files\microsoft visual studio\vc98\include\string(47) : error C2059: syntax error : '<'
  回复  更多评论
  

# re: VC6下使用STLPort 2008-10-30 10:28 guobosheng
续:

c:\program files\microsoft visual studio\vc98\include\string(49) : error C2803: 'operator ==' must have at least one formal parameter of class type
c:\program files\microsoft visual studio\vc98\include\string(49) : error C2805: binary 'operator ==' has too few parameters
c:\program files\microsoft visual studio\vc98\include\string(50) : error C2954: template definitions cannot nest
c:\program files\microsoft visual studio\vc98\include\string(51) : error C2143: syntax error : missing ',' before '<'
c:\program files\microsoft visual studio\vc98\include\string(51) : error C2059: syntax error : '<'
c:\program files\microsoft visual studio\vc98\include\string(53) : error C2803: 'operator !=' must have at least one formal parameter of class type
c:\program files\microsoft visual studio\vc98\include\string(53) : error C2805: binary 'operator !=' has too few parameters
c:\program files\microsoft visual studio\vc98\include\string(54) : error C2954: template definitions cannot nest
c:\program files\microsoft visual studio\vc98\include\string(56) : error C2143: syntax error : missing ',' before '<'
c:\program files\microsoft visual studio\vc98\include\string(56) : error C2059: syntax error : '<'
c:\program files\microsoft visual studio\vc98\include\string(57) : error C2803: 'operator !=' must have at least one formal parameter of class type
c:\program files\microsoft visual studio\vc98\include\string(58) : error C2954: template definitions cannot nest
c:\program files\microsoft visual studio\vc98\include\string(59) : error C2143: syntax error : missing ',' before '<'
c:\program files\microsoft visual studio\vc98\include\string(59) : error C2059: syntax error : '<'
c:\program files\microsoft visual studio\vc98\include\string(62) : error C2954: template definitions cannot nest
c:\program files\microsoft visual studio\vc98\include\string(63) : error C2143: syntax error : missing ',' before '<'
c:\program files\microsoft visual studio\vc98\include\string(63) : error C2059: syntax error : '<'
c:\program files\microsoft visual studio\vc98\include\string(65) : error C2803: 'operator <' must have at least one formal parameter of class type
c:\program files\microsoft visual studio\vc98\include\string(65) : error C2805: binary 'operator <' has too few parameters
c:\program files\microsoft visual studio\vc98\include\string(66) : error C2954: template definitions cannot nest
c:\program files\microsoft visual studio\vc98\include\string(68) : error C2143: syntax error : missing ',' before '<'
c:\program files\microsoft visual studio\vc98\include\string(68) : error C2059: syntax error : '<'
c:\program files\microsoft visual studio\vc98\include\string(69) : error C2803: 'operator <' must have at least one formal parameter of class type
c:\program files\microsoft visual studio\vc98\include\string(70) : error C2954: template definitions cannot nest
c:\program files\microsoft visual studio\vc98\include\string(71) : error C2143: syntax error : missing ',' before '<'
c:\program files\microsoft visual studio\vc98\include\string(71) : error C2059: syntax error : '<'
c:\program files\microsoft visual studio\vc98\include\string(74) : error C2954: template definitions cannot nest
c:\program files\microsoft visual studio\vc98\include\string(75) : error C2143: syntax error : missing ',' before '<'
c:\program files\microsoft visual studio\vc98\include\string(75) : error C2059: syntax error : '<'
c:\program files\microsoft visual studio\vc98\include\string(77) : error C2803: 'operator >' must have at least one formal parameter of class type
c:\program files\microsoft visual studio\vc98\include\string(77) : error C2805: binary 'operator >' has too few parameters
c:\program files\microsoft visual studio\vc98\include\string(78) : error C2954: template definitions cannot nest
c:\program files\microsoft visual studio\vc98\include\string(80) : error C2143: syntax error : missing ',' before '<'
c:\program files\microsoft visual studio\vc98\include\string(80) : error C2059: syntax error : '<'
  回复  更多评论
  

# re: VC6下使用STLPort 2008-10-30 10:28 guobosheng
续:

c:\program files\microsoft visual studio\vc98\include\string(81) : error C2803: 'operator >' must have at least one formal parameter of class type
c:\program files\microsoft visual studio\vc98\include\string(82) : error C2954: template definitions cannot nest
c:\program files\microsoft visual studio\vc98\include\string(83) : error C2143: syntax error : missing ',' before '<'
c:\program files\microsoft visual studio\vc98\include\string(83) : error C2059: syntax error : '<'
c:\program files\microsoft visual studio\vc98\include\string(86) : error C2954: template definitions cannot nest
c:\program files\microsoft visual studio\vc98\include\string(87) : error C2143: syntax error : missing ',' before '<'
c:\program files\microsoft visual studio\vc98\include\string(87) : error C2059: syntax error : '<'
c:\program files\microsoft visual studio\vc98\include\string(89) : error C2803: 'operator <=' must have at least one formal parameter of class type
c:\program files\microsoft visual studio\vc98\include\string(89) : error C2805: binary 'operator <=' has too few parameters
c:\program files\microsoft visual studio\vc98\include\string(90) : error C2954: template definitions cannot nest
c:\program files\microsoft visual studio\vc98\include\string(92) : error C2143: syntax error : missing ',' before '<'
c:\program files\microsoft visual studio\vc98\include\string(92) : error C2059: syntax error : '<'
c:\program files\microsoft visual studio\vc98\include\string(93) : error C2803: 'operator <=' must have at least one formal parameter of class type
c:\program files\microsoft visual studio\vc98\include\string(94) : error C2954: template definitions cannot nest
c:\program files\microsoft visual studio\vc98\include\string(95) : error C2143: syntax error : missing ',' before '<'
c:\program files\microsoft visual studio\vc98\include\string(95) : error C2059: syntax error : '<'
c:\program files\microsoft visual studio\vc98\include\string(98) : error C2954: template definitions cannot nest
c:\program files\microsoft visual studio\vc98\include\string(99) : error C2143: syntax error : missing ',' before '<'
c:\program files\microsoft visual studio\vc98\include\string(99) : error C2059: syntax error : '<'
c:\program files\microsoft visual studio\vc98\include\string(101) : error C2803: 'operator >=' must have at least one formal parameter of class type
c:\program files\microsoft visual studio\vc98\include\string(101) : error C2805: binary 'operator >=' has too few parameters
c:\program files\microsoft visual studio\vc98\include\string(102) : error C2954: template definitions cannot nest
c:\program files\microsoft visual studio\vc98\include\string(104) : error C2143: syntax error : missing ',' before '<'
c:\program files\microsoft visual studio\vc98\include\string(104) : error C2059: syntax error : '<'
c:\program files\microsoft visual studio\vc98\include\string(105) : error C2803: 'operator >=' must have at least one formal parameter of class type
c:\program files\microsoft visual studio\vc98\include\string(106) : error C2954: template definitions cannot nest
c:\program files\microsoft visual studio\vc98\include\string(107) : error C2143: syntax error : missing ',' before '<'
c:\program files\microsoft visual studio\vc98\include\string(107) : error C2059: syntax error : '<'
c:\program files\microsoft visual studio\vc98\include\string(111) : error C2954: template definitions cannot nest
c:\program files\microsoft visual studio\vc98\include\string(112) : error C2143: syntax error : missing ';' before '<'
c:\program files\microsoft visual studio\vc98\include\string(112) : error C2433: 'basic_istream' : 'inline' not permitted on data declarations
c:\program files\microsoft visual studio\vc98\include\string(112) : error C2501: 'basic_istream' : missing storage-class or type specifiers
c:\program files\microsoft visual studio\vc98\include\string(112) : error C2059: syntax error : ';'
c:\program files\microsoft visual studio\vc98\include\string(112) : error C2059: syntax error : '<'
c:\program files\microsoft visual studio\vc98\include\string(147) : error C2143: syntax error : missing ';' before '{'
c:\program files\microsoft visual studio\vc98\include\string(147) : fatal error C1003: error count exceeds 100; stopping compilation
Error executing cl.exe.

stl.obj - 102 error(s), 0 warning(s)



  回复  更多评论
  

# re: VC6下使用STLPort 2008-10-30 10:43 guobosheng
上面的问题解决了:

在楼主的第三步中:
3. 在VC6中使用STLport:
Tools->Options...->Directories中
include设置中添加目录:D:\STLport-5.1.2\stlport
library设置中添加目录:D:\STLport-5.1.2\lib

添加了上面两个目录后,需要把它们向上移,放在第一位。这样就没有问题了,至于为什么,我想可能是有的信息只有在上面两个目录下下才能找到吧,先找别的目录可能会因为找不到而出错。只是我的猜测,也不知道具体原因,请高手指点。  回复  更多评论
  

# re: VC6下使用STLPort[未登录] 2008-10-30 11:40 cc

楼主,在编译STLPort的过程中会报错

无法定位程序输入点RtlIpv4StringToAddressW于动态库ntdll.dll上

不过我用的STLPort 5.1.5  回复  更多评论
  


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   博问   Chat2DB   管理