现在的位置: 首页 > 综合 > 正文

[转]体验:VC++ .NET 2003 –安装和使用STLport 4.5.3 和LokiPort

2013年10月15日 ⁄ 综合 ⁄ 共 4988字 ⁄ 字号 评论关闭

“I want Visual C++ to be the C++ implementation of choice”      - Stanley Lippman

 

最近也就是两天前Windows Server 2003发布伴随着也发布了微软最新的开发工具Visual Studio.NET 2003,(其中的一些新特性之前在我的《Visual Studio.NET 2003新特性》中已经都说明了这里就不浪费篇幅了)你会发现整个Visual Studio.NET 2003中的Visual C++.NET的改善或是说新特性特别的突出,被认为宣传上最重要的四大亮点:

1.        Enhanced ISO C++ Conformance

2.        New Pentium IV, Athlon Optimizations

3.        Improved Code Security

4.        New Windows Forms

 

除了提供性能和安全性的加强之外,对于14则是让我感兴趣的,针对ISO C++ StandardVisual C++.NET的问题,目前微软出示的数据显示其兼容和符合标准的程度达到了98%

“The ISO C++ language standard defines several advanced features that have been conspicuously absent from previous versions of Visual C++.  Visual C++ .NET 2003 now implements roughly 98% of the standard-defined language features, a statistic that is on par with or better than the majority of commercial C++ compilers, on any platform.  In comparison, Visual C++ 6.0 implements roughly 81% of the ISO C++ standard; Visual C++ .NET 2002 implements 87% of the ISO C++ standard.”

 

确切的消息指出最早这个数据出自三个Test Suite中的Perennial,另外两家分别是Plumb Hall Dinkumware。并且Microsoft Visual C++.NET的产品经理Nick Hodapp也拿出具体的清单得出98%出自C++ ISO Standard的这些部分(更具体的信息见Chris Maunder的访谈录):

l          2.2 Unicode identifiers 

l          3.4.2 Full Koenig lookup 

l          8.5.1 Empty aggregate initialization 

l          9.8 Symbol lookup for local member functions 

l          11.4 Friends in class templates (also 14.5.3) 

l          13.3.1.1.2 Implicit invocation of ptr-to-func conversions 

l          13.3.3.2 Ranking of derived to base conversions 

l          14 Export keyword

l          14.1 Non-type template parameters (also 14.3.2)

l          14.5.2 User-defined conversion templates

l          14.5.4 Partial specialization of class templates

l          14.5.5.2 Partial ordering of function templates

l          14.6 Dependent name lookup

l          14.7.1 Nested classes in class templates

l          14.7.3 Explicit specialization of member templates

l          15.4 Exception specifications

l          15.5.2 The unexpected() function

 

We're not at 100%, yet, but expect that we'll remain on the path towards full conformance.  In particular, the ISO features "Export" and "Exception Specifications" are tricky, and there is much debate as to their usefulness.

 

对于14.6 微软承诺在下一个版本会实现.C++社团非常感兴趣的信息可能是Compile and use popular C++ community-written libraries including LOKI, BLITZ, and BOOST”冲着这句话和98%的高度兼容指标,抱着测试和验证的想法,我编译和测试了一些”C++ community-written libraries”。其一,验证一下是否真是如其言;其二,我也发现网络上抱有类似想法的人还不少,而进行的过程各不相同,所以是一种不错的体验或经历;其三,我发现这方面的中文资料太少,所以整理一份记录和相关资源与大家分享吧。于是也就有了这两篇文章,第一篇是关于STLport 4.5.3Loki,第二篇是关于Boost 1.30Blitz++ Library的体验.

 

    首先是Loki Library,这个类库就不用介绍太多,刚好最近Andrei Alexandrescu的《Modern C++ Design》一书中文版――C++设计新思维出版,有更多人会对它有更多更深的了解。对于这套类库其实不存在实现编译和安装的问题,一般是将需要的模块或功能通过Include到你的项目中,然后进行调用-编译-运行。总来说,Alexandrescu不是基于Visual C++来编写这个类库的,所以如果你真的直接用Visual C++ .NET来编译的话,可能也够你受的,我偷了懒,在网上我就找到了这方面的资源。并且Visual Studio.NET 2002我测试通过过,所以2003的版本我测过也没问题,剩下来就是资源的问题,找到合适的资源我想你就可以在办好你需要做的事情J

Original download:

http://moderncppdesign.com

http://sourceforge.net/projects/loki-lib/

VC6 +SP5 download:

http://fara.cs.uni-potsdam.de/~kaufmann/?page=lokiport

http://fara.cs.uni-potsdam.de/~kaufmann/?page=lokiexamples

VC7.0 + download:

http://www.geocities.com/rani_sharoni/LokiPort.zip

http://www.geocities.com/rani_sharoni/LokiPort.html

当然你也可以到我的网站上获得 Loki Library for VC++ 6.0 Loki Library for VC++ 7.0

你下载LokiPort_VC7.zip,将其解压到一个目录比如Visual Studio.NET 2003的安装目录下,然后就可以测试一下了,非常好的是这里面已经提供了每个模式的测试程序,你只用到tests目录中进行编译-运行就可以测试其编译器的情况了。

比如: cl /GX /MT /EHsc Test_XXXXX.cpp 然后运行-OK


 

 

当然有些比较特殊一点,我猜你会编译Test_SmartPtr.cpp第一次会出错,只要你按照Zip文档中的Readme上做就没有问题,换成下面的指令:

cl /GX /MT /GR /EHsc Test_SmartPtr.cpp ../SmallObj.cpp

 

CL.exe你有两点需要注意:

1.     保证你运行了 X:/Program Files/Microsoft Visual Studio .NET 2003/Vc7/bin/vsvars32.bat D:/Program Files/Microsoft Visual Studio .NET 2003/Common7/Tools/vsvars32.bat

2.      注意你的环境变量中INCLUDELokiPort的路径比如

@set INCLUDE=%MSVCDir%/LokiPort70;%MSVCDir%/ATLMFC/INCLUDE; …

C:> SET INCLUDE=C:/LokiPort70;%INCLUDE”

更简单的是使用Visual Studio.NET 安装程序组中的Visual Studio.NET 2003 Command Prompt

 

 

不过我建议你先备份你的vsvars32.bat然后直接修改这个文件,在加入Loki LibraryInclude的路径。

上述例子中我的Loki library在下面的路径:

D:/Program Files/Microsoft Visual Studio .NET 2003/Vc7/LokiPort70/tests>

 

啊哈,太简单了吧,当然Loki这样是可以过关了,如果都这么简单,我也就不用写这篇文章了,后面还有更多有趣的故事,接下来该 STLport了。

 

有关STLPort是什么,又怎么样,如何如何我就不用再多说J,我们直接入正题,装好用好才是关键

我使用的是STLport 4.5.3 安装目录:C:/STLport-4.5.3

Visual C++安装在D:/Program Files/Microsoft Visual Studio .NET 2003/Vc7/bin

 

你可以从这里进行Download http://www.stlport.com/download.html

Visual C++ 6.0的你可以在这篇文章中找到大部分资源和步骤,但对于在VC6中最新的4.5.3要编译通过还需要一个补丁见下面的”Bug fix for VC 6”

Using STLport with Microsoft Visual C++ 6

http://www.softadvances.com/articles/stlportusing.html

作者一个好的忠告J “Dinkumware's VC6 STL is $90; the others are free. While SGI's library works with VC6, it has problems with <iostream>. I haven't tried Dinkumware or Boost.” 不过这个建议对于Visual Studio.NET的用户来说似乎并不适用.

 

我则用了上面文章类似的步骤测试:

Download下来STLport-4.5.3.zip(1.2M) 解压缩之后,第一反应是需要设置你的INCLUDEPATH,在这两者中指明你的STLport Library的路径(见上面)

 

众所周知,Visual Studio.NET中带的STL库是P.J. Plauger写的一套STL类库(也是C++ STL一书的作者也是上面我们提到的Dinkumware公司的创始人之一),对于STLPort主要是强调多平台和多编译器,所以Visual C++.NET不是原生的就可以编译和支持,这个问题在Visual Studio.NET 2002(VC7.0)中就发现了,但就我看到的VC7.1中问题似乎更加严重了。

 

STLPort-4.5.3/src 中有你可以看到令你振奋的vc7.mak如果你直接执行nmake –f vc7.mak install,你会非常非常的沮丧,因为不会直接编译通过的。

通过不断地测试和阅读大量的讨论组,我发现总结,需要进行下面的修改:

1.       stlport/config/stl_msvc.h

抱歉!评论已关闭.