Connecting Tech Pros Worldwide Help | Site Map

using maps errors

Madni
Guest
 
Posts: n/a
#1: Mar 15 '06
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<unsigned short>,class std::allocator<unsigned short>[color=blue]
>,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?$p air@$$CBV?$basic_string@GU?$char_traits@G@std@@V?$ allocator@G@2@@std@@K@std@@@2@@std@@A)[/color]


any one plz help me in this

Regards ,
Madni

Mathias Waack
Guest
 
Posts: n/a
#2: Mar 15 '06

re: using maps errors


Madni wrote:
[color=blue]
> 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<unsigned short>,class std::allocator<unsigned short>[color=green]
>>,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[/color][/color]
$char_traits@G@std@@V?$allocator@G@2@@std@@KU?$les s@V?$basic_string@GU
$char_traits@G@std@@V?$allocator@G@2@@std@@@2@V?$a llocator@U?$pair@$$CBV
$basic_string@GU?$char_traits@G@std@@V
$allocator@G@2@@std@@K@std@@@2@@std@@A)[color=blue]
>
>
> any one plz help me in this[/color]

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
Sunil Varma
Guest
 
Posts: n/a
#3: Mar 15 '06

re: using maps errors



Madni wrote:[color=blue]
> 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<unsigned short>,class std::allocator<unsigned short>[color=green]
> >,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?$p air@$$CBV?$basic_string@GU?$char_traits@G@std@@V?$ allocator@G@2@@std@@K@std@@@2@@std@@A)[/color]
>
>
> any one plz help me in this
>
> Regards ,
> Madni[/color]

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.

Madni
Guest
 
Posts: n/a
#4: Mar 15 '06

re: using maps errors


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;

};

Madni
Guest
 
Posts: n/a
#5: Mar 15 '06

re: using maps errors


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

Closed Thread