我收到以下错误消息(有人可以随意编辑不必要的位):
1>FIXDecoder.obj:错误 LNK2001:无法解析的外部符号“私有:静态类 std::unordered_map,类 std::allocator >,类 std::basic_string,类 std::allocator >,struct std::hash,类 std ::allocator > >,struct std::equal_to,class std::allocator > >,class std::allocator,class std::allocator > const ,class std::basic_string,class std::allocator > > > > FD ::FixValueMappingsDict" (?FixValueMappingsDict@FD@@0V?$unordered_map@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@U?$hash @V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@U?$equal_to@V?$basic_string@DU?$char_traits@D@std @@V?$allocator@D@2@@std@@@2@V?$allocator@U?$pair@$$CBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@ D@2@@std@@V12@@std@@@2@@std@@A)
1>FD.obj:错误LNK2001:未解析的外部符号“私有:静态类std::unordered_map,类std::allocator>,类std::basic_string,类std::allocator>,struct std::hash,类std ::allocator > >,struct std::equal_to,class std::allocator > >,class std::allocator,class std::allocator > const ,class std::basic_string,class std::allocator > > > > FD ::FIXFieldNoDict" (?FIXFieldNoDict@FD@@0V?$unordered_map@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@U?$hash @V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@U?$equal_to@V?$basic_string@DU?$char_traits@D@std @@V?$allocator@D@2@@std@@@2@V?$allocator@U?$pair@$$CBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@ D@2@@std@@V12@@std@@@2@@std@@A)
1>C:\visual studio 2012\Projects\FD\x64\Debug\FD.exe : 致命错误 LNK1120: 2 unresolved externals
对于此代码:
//FH.h
#ifndef FD_H
#define FD_H
#include "FM.h"
#include <unordered_map>
#include <string>
class FD{
public:
FD();
FD(FM message);
~FD();
FD(const FD& tocopy);
FD& operator=(const FD& toassign);
private:
static unordered_map<string,string> FIXFieldNoDict;
static unordered_map<string,string> FixValueMappingsDict;
};
#endif
//FD.cpp
#include "FD.h"
#include "Mappings.h"
#include "Utils.h"
#include <vector>
#include <string>
#include <iostream>
#include <unordered_map>
using namespace std;
FD::FD(){
FIXFieldNoDict = Mappings::createFIXFieldNoDict();
FixValueMappingsDict = Mappings::getFIXValuesDict();
}
Mappings.h 仅包含一些创建 unordered_map 的函数
#ifndef MAPPINGS_H
#define MAPPINGS_H
#include <unordered_map>
#include <string>
using namespace std;
class Mappings{
public:
Mappings();
static unordered_map<string,string> createFIXFieldNoDict();
static unordered_map<string,string> getFIXValuesDict();
.
.
};