using maps errors

M

Madni

Hi,

WHile iam trying to build my project holding a class carrying map (STL)
as a static data member the following link2001 error is reported .:

WESFWDeviceManager error LNK2001: unresolved external symbol "private:
static class std::map<class std::basic_string<unsigned short,struct
std::char_traits said:
,unsigned long,struct std::less<class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > >,class std::allocator<struct std::pair<class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > const ,unsigned long> > > CDeviceLicenseMgr::m_mapDriversCount" (?m_mapDriversCount@CDeviceLicenseMgr@@0V?$map@V?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@KU?$less@V?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@@2@V?$allocator@U?$pair@$$CBV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@K@std@@@2@@std@@A)


any one plz help me in this

Regards ,
Madni
 
M

Mathias Waack

Madni said:
Hi,

WHile iam trying to build my project holding a class carrying map (STL)
as a static data member the following link2001 error is reported .:

WESFWDeviceManager error LNK2001: unresolved external symbol "private:
static class std::map<class std::basic_string<unsigned short,struct
$char_traits@G@std@@V?$allocator@G@2@@std@@KU?$less@V?$basic_string@GU
$char_traits@G@std@@V?$allocator@G@2@@std@@@2@V?$allocator@U?$pair@$$CBV
$basic_string@GU?$char_traits@G@std@@V
$allocator@G@2@@std@@K@std@@@2@@std@@A)


any one plz help me in this

Not really - without seeing any code I can only guess. But maybe its worth
reading FAQ 10.11. at http://www.parashift.com/c++-faq-lite.

Mathias
 
S

Sunil Varma

Madni said:
Hi,

WHile iam trying to build my project holding a class carrying map (STL)
as a static data member the following link2001 error is reported .:

WESFWDeviceManager error LNK2001: unresolved external symbol "private:
static class std::map<class std::basic_string<unsigned short,struct



any one plz help me in this

Regards ,
Madni

Seems you have not defined the map object globally.
Could you post the code you are getting error so that we can look into
furthur.
 
M

Madni

thanks for reply .... yes my map object is not declared globally rather
its a static data member ... i wonder if i could use map as a static
member as i have never use it like before ... any ways following is a
header file carrying the map object declaration and its use ....
WESString is a wrapper class

#include <MAP>
using namespace std;

typedef map<WESString,DWORD>::iterator MAPITR;
class CDeviceLicenseMgr
{
public:
CDeviceLicenseMgr(void);
virtual ~CDeviceLicenseMgr(void);

inline static DWORD getActiveDAClientCount (WESString wstrDriverName)
{
CSQSCriticalSectionGuard cs(m_cs);
MAPITR itr = m_mapDriversCount.find(wstrDriverName);
if(itr != m_mapDriversCount.end()) // if driver is there
{
return itr->second;

}

return 0; // driver not found
}

inline static void setActiveDAClientCount (WESString wstrDriverName,
DWORD dwCount)
{
CSQSCriticalSectionGuard cs(m_cs);
MAPITR itr = m_mapDriversCount.find(wstrDriverName);
if(itr != m_mapDriversCount.end())
{
itr->second = dwCount;
}

}

inline static void incrementActiveDAClientCount (WESString
wstrDriverName)
{
CSQSCriticalSectionGuard cs(m_cs);
MAPITR itr = m_mapDriversCount.find(wstrDriverName);
if(itr != m_mapDriversCount.end()) // if driver name is in the map
{
DWORD temp = itr->second;
temp++;
itr->second = temp;
}
else // add driver name in the map and initialize count to 1
{
m_mapDriversCount.insert(make_pair(wstrDriverName,1));
}
}

inline static void decrementActiveDAClientCount (WESString
wstrDriverName)
{
CSQSCriticalSectionGuard cs(m_cs);
MAPITR itr = m_mapDriversCount.find(wstrDriverName);
if(itr != m_mapDriversCount.end())
{
DWORD temp = itr->second;
temp--;
itr->second = temp;
}
//dwActiveDAClientCount-- ; find driver in map and decrement
accordingly
}

static bool validateActiveDAClientCountLicense(WESString
wstrDriverName);
static HRESULT validateLicenseForNewActiveDAClient(const WESContext
&a_wcx, WESString wstrDriverName);
static void updateLicenseForDeleteActiveDAClient(const WESContext
&a_wcx, WESString wstrDriverName);

private:
static DWORD dwExternalDAClientCount;
static DWORD dwActiveDAClientCount;
static CSQSCriticalSection m_cs;
static map<WESString,DWORD> m_mapDriversCount;

};
 
M

Madni

i've figured out the problem ...on the top of the DeviceLicenseMgr.cpp
i should put the line :
map<WESString,DWORD> CDeviceLicenseMgr::m_mapDriversCount;

this resolves the issue ,.... thanks all u guys for ur positive replies
...

Madni
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,143
Latest member
DewittMill
Top