Linker error when using unique_ptr in C++/CLI

纵饮孤独 提交于 2019-11-30 19:30:30

Well, don't know how relevant it is now, but I had exactly same problem with C++/CLI and solved it with taking r-value reference instead of value. I mean: void setUniquePtr(unique_ptr&& a, unique_ptr&& b)

This way it compiles though it's not a cleanest way to do things.

Reading through that complex error message, I think it's complaining that the LinAlgPoint3 struct doesn't have a copy constructor. Try implementing the copy constructor, and maybe operators = and ==, and see if that fixes it.

You can't pass C++ objects between DLLs and expect it to work right.

Memory layout can be different in different modules. Different allocators are almost certainly being used (this shoots down any C++ type that owns memory, including string, vector, and unique_ptr).

Use of pointers to pure virtual base classes can help with this.

Or, if you have the source code for the C++ part, try linking the C++ and C++/CLI into a single DLL, instead of referencing C++ code in a separate DLL.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!