An attempt to use STL in *.cu file How to avoid linker errors ?

I have an application that is based on MFC, consequently, all the STL-related stuff is already included when linking. I’d like to use std::string class in my *.cu file, and when I try to do it (#include … string str = “…”) it compiles just fine, however, linker can’t link the whole application as std::string is defined in two modules (in mfc and cu).

How to avoid this conflict ?

Thanks in advance.

Upgrade to VS2005 SP1.

That solved CRAZY linker errors (w.r.t STL) for me

Already have one.

Here is the typical message:


msvcprtd.lib(MSVCP80D.dll) : error LNK2005: “public: __thiscall std::basic_string<char,struct std::char_traits,class std::allocator >::~basic_string<char,struct std::char_traits,class std::allocator >(void)” (??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ) already defined in

Do you use MFC in a Shared DLL? I have no problem linking programs when I use MFC in Static Libraries or select the “Use Standard Windows Libraries” in project properties. Using the DLL produces a wall of linker errors.

I see … yeah, will try static linkage.