tags:

views:

167

answers:

2

I just reorganized some libraries of my Visual C++ (7.1) project and got trouble with the linker i cannot resolve.

The Project links MFC as well as Standard Windows Libraries, all MBCS

Somewhere, there is something like :

std::stringstream sstr; sstr << m_MyCStringVar << std::endl;

(this line, as well as some others, needs << for basic_stream and CString)

Everything was fine until i merged 2 other libraries into 1 libraries (just moving the code/files from a to b without changing much)

Suddenly, all my exe's produce the linker error:

BasicFunctionsD.lib(CAccess.obj) : error LNK2019: unresolved external symbol "class std::basic_ostream > & __cdecl operator<<(class std::basic_ostream > &,class ATL::CStringT > > const &)" (??6@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@std@@AAV01@ABV?$CStringT@DV?$StrTraitMFC_DLL@DV?$ChTraitsCRT@D@ATL@@@@@ATL@@@Z) referenced in function "protected: void __thiscall CAccessor::CreateCategory(int,char const *,char const *)" (?CreateCategory@CAccessor@@IAEXHPBD0@Z)

(above code wasn't affected from the library merge, at least not directly)

As far as i can recognize, the << operator for basic ostream and CString is not found.

Maybe the lib containing MFC versions of basic_ostream is not found?

But i have no idea how to fix it or even where to start searching for the real problem.

Any hints would be nice

+1  A: 

I'm probably wrong but IIRC i did experience a problem with unresolved links. The solution was get ready...... #include <string>. Turns out one of the headers defined string and i was able to use string normally and compile with no problem. However there was no static implementation since i forgot the header so maybe your missing one.

i don't think it could be something with std::string, the MFC's CStringT operator/interface to std::basic_*stream seems to be the problem. But i keep an eye on the <string> includes
RedFraggle
+3  A: 

arg...

Simple reason: there is no std::ostream operator with CString... it was my own code and i just did not remember... :( During cleanup , the function went into a namespace and got lost

D'oh!

namesspace StupidcleanupIshouldNotHavedone { std::ostream & operator<<(std::ostream & s, const CString & str) { s << (LPCTSTR)str; return s; } }

RedFraggle