views:

57

answers:

1

Hi all,

I've created a class with a boost::unordered_map as a member,

Linkage.h

#ifndef LINKAGE_H
#define LINKAGE_H

#include <boost/unordered_map.hpp>

class Linkage
{
private:
    boost::unordered_map<int, int> m_IOMap;
public:
         ....
};

Linkage.cpp

#include "stdafx.h"

... // methods

and in the managed side of C++, I try to create the pointer of the obj:

private: System::Void Form1_Load(System::Object^  sender, System::EventArgs^  e) {
    Linkage* m_pLink = new Linkage();
         .....
}

However this produces errors:

Error   4   error LNK2005: "private: static unsigned int const boost::detail::type_with_alignment_imp<4>::found" (?found@?$type_with_alignment_imp@$03@detail@boost@@$$Q0IB) already defined in Proj_Test.obj   Linkage.obj
.....
Error   7   fatal error LNK1169: one or more multiply defined symbols found

Could anyone explain to me pls? Thanks.

A: 

Eventually this works when I explicitly instantiate it inside the constructor:

#include "stdafx.h"

Linkage::Linkage()
{
    template boost::unordered_map<int, int>;
}