From: Rick Sivernell on
List

I have a major problem, I have code that was originally created in Linux and
uses stl and wxWidgets together. Works very nice on 32/64 systems. When I take
the code to Win XP Pro, using MSDEV 2005 express, it fails apart. I have
rewritten it using the #ifdef __WXMSW__ and have it working except for one final
problem, __declspec(dllimport)
public: __thiscall wxString::operator wchar_t const *(void)const " (__imp_??
BwxString@@QBEPB_WXZ), compiles with no warning and no errors but on link it
fails. If I remove l_IT[l_iIndex] which in this method is from
typedef m_vwxDataStrings m_wxIT; and has wxString data. I have tried everything
and all get back to wxChar or wxCharBuffer and then fails. In IMHO MS has screwed
this STL system in their normal way. I do not understand this use of typedef ing:
typedef vector<string> m_vDataStrings;
typedef vector<wxString> m_vwxDataStrings;
typedef m_vDataStrings m_IT;
typedef m_vwxDataStrings m_wxIT;

My code is in a shared lib in Linux and a shared dll in MS. How do I fix this,
recompile wxWidgets and add WXxxxxxx declaration on all classes?

**************** Code sample and link errors **********************

Registry.h:
class CRegistry
{

public:
CRegistry();
....
bool OnWriteData( vector<wxString> p_vszData);


private:

#ifdef __WXMSW__
typedef vector<string> m_vDataStrings;
typedef vector<wxString> m_vwxDataStrings;
typedef m_vDataStrings m_IT;
typedef m_vwxDataStrings m_wxIT;
#else
vector<string> m_vDataStrings;
#endif
};


Registry.cpp:
bool CRegistry::OnWriteData( vector<wxString> p_vszData)
/*
Go to the end of the file & append data there, from the beginning
to the end of the vector of strings
*/
{
fstream l_StringOut(m_szFileName.c_str());
wxString l_szData;
int l_iIndex = 0;

#ifdef __WXMSW__

m_wxIT::iterator l_IT;
m_vwxDataStrings l_vszData = p_vszData;
size_t l_iDataIndex = 0;

if(l_StringOut.fail())
{
cout << "CRegistry::OnWriteData : failed to open " << m_szFileName <<
" for writing. Returning false" << endl;
return false;
}
l_StringOut.seekg(0,ios::end); // move to the end of file

for(l_IT = l_vszData.begin();
l_IT != l_vszData.end();
l_IT++, l_iIndex++)
{
l_StringOut << /*l_IT[l_iIndex] <<*/ ("\n"); ######## doe not like l_IT[l_
iIndex]} l_StringOut << ("\n\n");

l_StringOut.seekg(0,ios::end); // move to the end of file
l_szData .Empty( );
for(l_IT = l_vszData.begin();
l_IT != l_vszData.end();
l_IT++,l_iIndex++)
{
if( (l_iIndex) )
{
l_StringOut << ('[') << l_IT[l_iIndex] << (']') << ("\n\n\n"); #####
}
}
l_StringOut << ("\n\n");
l_StringOut.close();

#else
vector<wxString>::iterator l_IT;

if(l_StringOut.fail())
{
cout << "CRegistry::OnWriteData : failed to open " << m_szFileName <<
" for writing. Returning false" << endl;
return false;
}
l_StringOut.seekg(0,ios::end); // move to the end of file

for(l_IT = p_vszData.begin();
l_IT != p_vszData.end();
l_IT++)
{
l_szData = l_IT->c_str();
l_StringOut.write(l_szData.c_str(),l_szData.length());
l_StringOut.write("\n",strlen("\n"));
}
l_StringOut.write("\n\n",strlen("\n\n"));
l_StringOut.seekg(0,ios::end); // move to the end of file
l_szData .Empty( );
for(l_IT = p_vszData.begin();
l_IT != p_vszData.end();
l_IT++,l_iIndex++)
{
if( (l_iIndex) )
{
l_szData = wxT('[');
l_szData += l_IT->c_str();
l_szData += wxT(']');
l_StringOut.write(l_szData.c_str(),l_szData.length());
l_StringOut.write("\n\n\n",strlen("\n\n\n"));
}
}
l_StringOut.write("\n\n",strlen("\n\n"));
l_StringOut.close();
#endif
return true;
}

Compile & Link:
Generating Code...
Compiling resources...
Compiling manifest to resources...
Linking...
Creating library Debug/Registry.lib and object Debug/Registry.exp
Registry.obj : error LNK2019: unresolved external symbol "__declspec(dllimport)
public: __thiscall wxString::operator wchar_t const *(void)const " (__imp_??
BwxString@@QBEPB_WXZ) referenced in function "public: bool __thiscall
CRegistry::OnWriteData(class std::vector<class wxString,class
std::allocator<class wxString> > &)" (?OnWriteData(a)CRegistry@@QAE_NAAV?
$vector(a)VwxString@@V?$allocator(a)VwxString@@@std@@@std@@@Z) Debug/Registry.dll :
fatal error LNK1120: 1 unresolved externals Build log was saved at "file://f:\D&R
\C++\src\ConMan\Registry\Debug\BuildLog.htm" Registry - 2 error(s), 0 warning(s)
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========

--
Rick Sivernell
Dallas, Texas 75287
972 306-2296
ricksivernell(a)verizon.net
Registered Linux User


---------------------------------------------------------------------
To unsubscribe, e-mail: wx-users-unsubscribe(a)lists.wxwidgets.org
For additional commands, e-mail: wx-users-help(a)lists.wxwidgets.org