Archived

This topic is now archived and is closed to further replies.

hollowMedia

Beginning STL with Visual C++ 6.0

Recommended Posts

Not having a very easy time to start with. First, when I include without the .h, I get a list of errors a mile long [with the .h, I''m fine]. I''ve since downloaded SGI''s STLPort and added that directory to my include path, but more strange happenings occur. If I declare a variable, let''s say: std::ofstream x; Then type x. The autocompletion picks it up and allows me to grab the proper functions, but when I go to compile it tells me that std doesn''t exist and/or ofstream is not a part of std. When I try to use the namespace std, it gives me the former message as well. I''ve searched around a bit trying to find something, but I''ve yet to see much. I''m downloading SP5 for VS6.0 in hopes that it may help, but I''m not too sure. Any suggestions? Thanks.

Share this post


Link to post
Share on other sites
to use stlport''s iostream you must make the library. go to stlport site to see the docs. and go to their forums, alot of informations on how to build the libs there.

the autocompletation is using the microsoft stl, at least is what it does to me.

Share this post


Link to post
Share on other sites
also, there''s a good deal of info on the OGRE site about installing STLPort (as OGRE uses it)

I installed it and it was quite straightforward.
here''s their info:

-Download STLport 4.5.3 from www.stlport.org
and unzip it somewhere

-Open a command prompt, and change to the folder STLport-4.5.3\src

-If you''re running VC, make sure you have run ''vcvars32.bat'', which is located in your devstudio\vc6\bin or VisualStudio.Net\vc7\bin folder. Make sure this runs successfully.

If you''re using Visual C++ 6:
type ''nmake -f vc6.mak clean all''
type ''nmake -f vc6.mak install''

If
you''re using Visual C++.Net:
type ''nmake -f vc7.mak clean all''
type ''nmake -f vc7.mak install''

If you''re using gcc 2.9x:
type ''./configure''
type ''make''
type ''make install''

-Open Microsoft Visual C++ and select Tools | Options... from the menu bar to bring up the options dialog

-Go to the include folders list: in VC6 this is on the ''Directories'' tab, in VC++.Net it is under Projects|VC++ Directories in the tree on the left

-Make sure the stlport include directory is at the TOP of your include folders list. Crucially, it MUST be above all Microsoft include folders.

-Close VC++ to save the settings

-----------------------
"Without a sense of humour we couldn''t react to a lot of things"

Share this post


Link to post
Share on other sites
You shouldnt include the .h in any standard c++ header files.
If your doing what i think your doing, remove all the .h''s from your #includes and type

using namespace std;

at the top of you .cpp

hope that helps

Share this post


Link to post
Share on other sites
Or you could just use the STL that comes with VC6.

#include <list>

std::list whatever;

-- Steve --

Share this post


Link to post
Share on other sites
Thanks for all of the replies.

First, I was actually using a version that I downloaded from SGI.com, which looks like it was just a wrapper for MS''s iostream. I thought it was STLPort from the context of an article, but it was not.

Second, I tried using MS''s stl, but as I said, it will not let me use std. I''ve written apps with STL on compilers that were already set up properly, so I''ve not seen this before.

I''ve run the batch file to set up the environment variables and went forward with building STLPort''s, but on the install it fails stating that MSVCDir is not set up, but upon viewing my environment variables, it is. So, what I did was remove all of the environment variables associated and re-ran the batch file and then installed (make -f vc6.mak install), and it seems to have installed OK.

Thanks for the help, but I''m still confused as to why iostream isn''t working by default (which is again, why I even tried the .h). As soon as I try the std namespace, I get :
"''std'' : does not exist or is not a namespace"

Either way, it will work now since I''ve installed an STL with a real iostream in it. Thanks, especially to you jhavna.

Share this post


Link to post
Share on other sites
Either type: using namespace std; or prepend ''std::'' to container''s name like so std::vector ints;

The SGI stl didn''t work for me either but latest non-beta STLPort runs in wrapper mode and works perfect for me. I haven''t tried building the stl lib yet. The stlport is configured to run with its own streams by default after building the lib. SGI stl is considered obsolete. Their docs omit several methods as I found out when I compared the docs to their headers. I now use c++ standard docs for reference to stlport lib. Hash maps, rope and perhaps something else is not mentioned in c++ standard as those features are not part of the standard.

Share this post


Link to post
Share on other sites
Ah so VC++ 6''s STL is not real? Wonder why they did put it in there then. iostream.h is deprecated and has no namespace, while iostream is the standard one. VC++''s STL is not perfect, but most stuff will work, especially streams.


#include <fstream> // ofstream

#include <iostream> // cout


int main()
{
std::ofstream x;
std::cout << "See, it works" << std::endl;
return 0;
}

Share this post


Link to post
Share on other sites
It''s real but is less compliant with the standard and isn''t kept up to date anymore(unless you buy new one from dinkum). The size() with lists I think is one snag(though I prefer it). STLPort is more up to date and long time ago when I was dinking with SGI stl it was couple of times faster than vc++6 stl. Other than that, vc++6 stl is pretty good, I had no problems with it before I switched to stlport.

Share this post


Link to post
Share on other sites