Reputation: 1
For an project I want to use the nice paho.mqtt.cpp SDK and have to use it with the old msvc10. The paho.mqtt.cpp uses c+11 extensions massively so I had to modify a lot of source code to get it working with the msvc10 compiler. Must of the stuff could be replaced by boost and I am now able to compile and link the library itself.
When I try to use this modified paho.mqtt.cpp-msvc10-library in other projects i always get linking errors. They look like:
LNK2019 unresolved external symbol "public: __cdecl mqtt::buffer_ref<char>::buffer_ref<char>(class mqtt::buffer_ref<char> &&)" (??0?$buffer_ref@D@mqtt@@QEAA@$$QEAV01@@Z) referenced in function "class boost::shared_ptr<class mqtt::message> __cdecl boost::make_shared<class mqtt::message,class mqtt::buffer_ref<char>,void const * &,unsigned __int64 &,int &,bool &>(class mqtt::buffer_ref<char> &&,void const * &,unsigned __int64 &,int &,bool &)" (??$make_shared@Vmessage@mqtt@@V?$buffer_ref@D@2@AEAPEBXAEA_KAEAHAEA_N@boost@@YA?AV?$shared_ptr@Vmessage@mqtt@@@0@$$QEAV?$buffer_ref@D@mqtt@@AEAPEBXAEA_KAEAHAEA_N@Z) async_consume
LNK2001 unresolved external symbol "public: __cdecl mqtt::buffer_ref<char>::buffer_ref<char>(void)" (??0?$buffer_ref@D@mqtt@@QEAA@XZ) async_consume
LNK2001 unresolved external symbol "public: class mqtt::buffer_ref<char> & __cdecl mqtt::buffer_ref<char>::operator=(class mqtt::buffer_ref<char> &&)" (??4?$buffer_ref@D@mqtt@@QEAAAEAV01@$$QEAV01@@Z) async_consume
and some more of the same sort...
The same is happening when I try to build the delivered examples in the paho.mqtt.cpp SDK.
Does anybody has any Ideas? All the source is available at https://github.com/eclipse/paho.mqtt.cpp
It might be a similar case as in: Why am I getting unresolved externals? but I am not able the find the missing template in case...
I'm on the way to fix it on my own...the problem are the move and copy operators in c+11. The default operators were deleted by my conversion but I forgot to implement them by my own:
For example: Copy operator before:
buffer_ref& operator=(const buffer_ref& rhs)= default
For c+0x we have to implement it by our own:
buffer_ref& operator=(const buffer_ref& rhs)
{
//added copying by spiesra
if (this != &rhs)
{
data_.reset();
data_ = rhs.ptr();
data_.reset(new blob(reinterpret_cast<const value_type*>(rhs.data()), rhs.size()));
}
return *this;
}
or the move operator in c+11
buffer_ref& operator=(buffer_ref&& rhs) == default
and our own implementation:
buffer_ref& operator=(buffer_ref&& rhs)
{
//added moving by spiesra
if (this != &rhs)
{
data_.reset();
data_ = rhs.ptr();
rhs.reset();
}
return *this;
}
Are my own implemantations are correct?
Upvotes: 0
Views: 89