VC++ and STL (SGI Implementation) 
Author Message
 VC++ and STL (SGI Implementation)

Hi!

I'm trying to use the SGI STL implementation ( from the STLPort project, at
http://www.*-*-*.com/ ~fbp/stl/ ) in MS VC++, together with MFC classes.

This small test program compiles, but doesn't link:

#include <afx.h>

#include <list.h>

typedef list<char> myList;

void main ()
{

myList lst;

lst.push_front ( 'A' );
lst.push_front ( 'B' );

for ( myList::iterator Cursor = lst.begin ();
   Cursor != lst.end ();
   Cursor ++ )
{
  cout << *Cursor << endl;

Quote:
}
}

Linker error:


libcmtd.lib>

The same error occurres if I use the Microsoft STL (list rather than
list.h).

Seems to me that vc++ gets puzzled with its own STL implementation. How can
I prevent the use of of the Microsoft STL? How can I make the code work?

I want to use the STL in our company, but it has to work with all VC++
projects without great efforts.

tia, Thomas Stfe



Mon, 06 Nov 2000 03:00:00 GMT  
 VC++ and STL (SGI Implementation)

If it's conflicting with one of the MFC libraries, I'm having the same
problem.  It didn't occur to me that it was related to STL, though.

The only workaround for it that I've found is to use the /FORCE linker
command.
You can select it in the IDE - Project!Settings...!Linker!Customize has a
box called
"Force file output" that turns this error into a warning, but links.  In my
case,
I haven't seen any problems with this, though the message is worrisome.

Quote:

>Hi!

>I'm trying to use the SGI STL implementation ( from the STLPort project, at
>http://www.metabyte.com/~fbp/stl/ ) in MS VC++, together with MFC classes.

>This small test program compiles, but doesn't link:

>#include <afx.h>

>#include <list.h>

>typedef list<char> myList;

>void main ()
>{

>myList lst;

>lst.push_front ( 'A' );
>lst.push_front ( 'B' );

>for ( myList::iterator Cursor = lst.begin ();
>   Cursor != lst.end ();
>   Cursor ++ )
>{
>  cout << *Cursor << endl;
>}

>}

>Linker error:


>libcmtd.lib>

>The same error occurres if I use the Microsoft STL (list rather than
>list.h).

>Seems to me that vc++ gets puzzled with its own STL implementation. How can
>I prevent the use of of the Microsoft STL? How can I make the code work?

>I want to use the STL in our company, but it has to work with all VC++
>projects without great efforts.

>tia, Thomas Stfe



Tue, 07 Nov 2000 03:00:00 GMT  
 VC++ and STL (SGI Implementation)

Hi Thomas,

be sure to compile your Debug version with Debug Multithreaded DLL and the
Release with Multithreaded DLL. Use always the debug version ot the run-time
libraries for your debug version. Also remove all this DEBUG_NEW defines
that are included by the VC-Wizards in all cpp files. This macro redefines
the new operator which will not work correct in conjunction with the STL
(from MS or SGI) and lead to a lot of memory leaks in the debug version.

Joerg
Greetings from the Black Forest, Germany
Remove 'nonsense.' to reply


Quote:
>Hi!

>I'm trying to use the SGI STL implementation ( from the STLPort project, at
>http://www.metabyte.com/~fbp/stl/ ) in MS VC++, together with MFC classes.

>This small test program compiles, but doesn't link:

[...]

>Linker error:


>libcmtd.lib>

>The same error occurres if I use the Microsoft STL (list rather than
>list.h).

[...]


Wed, 08 Nov 2000 03:00:00 GMT  
 VC++ and STL (SGI Implementation)

Quote:

> If it's conflicting with one of the MFC libraries, I'm having the same
> problem.  It didn't occur to me that it was related to STL, though.

Actually, I think the problem is with MFC that defines its own new and
delete operators, and if the linker finds the "ordinary" (standard) ones
first, it barfs on the MFC-ones. You have to make sure that the
MFC-library is searched before the standard cpp-library. You can do this
by putting the relevant mfc-library as an "Additional library path" on
the Linker-Input tab. You can also use the /VERSOSE:LIB project option
(have to be input manually) to assure yourself that the libraries are
searched in correct order.

Why the linker does NOT complain when the libraries are included in the
reverse (correct?) order, I have no idea. You would think the problem
would be the same; multiply defined new and delete operators.

This "feature" is actually documented but very well hidden. It took me
some hours (too many) to find, and now I cannot remember where it is.
--
Martin Fabian
------------------------------------------------------------------------

     tel: +46 (0)31 772 37 16        | Chalmers University of Technology
     fax: +46 (0)31 772 37 30        |       S-412 96 Gothenburg
                                     |              Sweden
Homepage: http://www.control.chalmers.se/~fabian
------------------------------------------------------------------------
Everyone is talking about real-time, but how real is time, really?



Fri, 10 Nov 2000 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. VC++ and STL (SGI Implementation)

2. Conflict between VC 7 STL and SGI STL - how to resolve

3. ATL conflict between VC 7 STL and SGI STL - how to resolve

4. SGI-STL or STL of VC++

5. VC++ STL v/s SGI STL Performance ???

6. sgi STL & vc++ 6.0

7. SGI STL and VC++ 5.0

8. VC 5.0 and SGI STL

9. SGI STL w/vc 5.0?

10. SGI-STL and VC++ 5.0

11. how to use stl of sgi in VC++?

12. VC 6 and SGI STL 3.11

 

 
Powered by phpBB® Forum Software