C++ link error: missing Orphan_all(), Container_base12(), Xlength_error
Hi all. I recently incorporated more C++ into my Max external dp.kinect. The latest round of inclusion is now causing linker errors when linked against the Max private libraries (the default behavior). I use Microsoft Visual C++ 2010 Express. Below are those errors.
Any ideas on how to circumnavigate this? Here is what I have done and learned so far:
- I traced this to the Max private libraries by noticing this issue only when I compiled my Retail build. Debug works fine. This is due to the Max headers defining use of the Microsoft libraries in debug but the Max private libraries in the Retail.
- I can link against the Microsoft libraries using MAXAPI_USE_MSCRT. This works well. However, this might create more effort for a person to install my external; now needing specific runtime components installed.
- These 4 missing functions are all contained with a Microsoft C++ header called xutility
- Have found some related posts, but nothing actionable by me yet like:http://social.msdn.microsoft.com/Forums/en-US/vclanguage/thread/c72237b1-2f7c-42cc-ad47-299806f33370http://stackoverflow.com/questions/11572845/why-is-visual-c-2010-still-calling-orphan-all-when-a-vector-is-destroyed-with
1>KinectAudioStream.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) void __cdecl std::_Xlength_error(char const *)" (__imp_?_Xlength_error@std@@YAXPBD@Z) 1>KinectAudioStream.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __thiscall std::_Container_base12::_Orphan_all(void)" (__imp_?_Orphan_all@_Container_base12@std@@QAEXXZ) 1>KinectAudioStream.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall std::_Container_base12::~_Container_base12(void)" (__imp_??1_Container_base12@std@@QAE@XZ) 1>KinectAudioStream.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall std::_Container_base12::_Container_base12(void)" (__imp_??0_Container_base12@std@@QAE@XZ)
I continue to experience this difficulty with Max SDKs 6.1.1 and 6.1.3 both with VC Express 2012.
I suspect it is related to having some C++ objects which I call into. Only when I compile against the Microsoft MSVCRT does it compile. I am so far unable to use the runtimes shipped with Max.
It sounds like you have probably diagnosed this correctly. FWIW, in my own private externals I link statically to the MS runtime and have not had any problems doing things that way.
- .. –
Ok. Good to hear my approach is similar to that of an experienced Max dev like yourself is doing.
For those reading…it is possible to successfully link against the MS C DLL runtime (/MD) and use the preprocessor define MAXAPI_USE_MSCRT. However, this could cause a scenario where someone using the external might need to download the MS C runtime. Its a small runtime, but is a potential extra step.
Instead, I now statically link using: /MT and MAXAPI_USE_MSCRT
Compiles, runs, no errors, no runtime download.
There are some esoteric caveats for statically linking. Microsoft write to some of the issues here http://msdn.microsoft.com/en-us/library/abx4dbyh(v=vs.110).aspx
I am really glad you figured this out already and I stumbled on this post. I was pulling hairs for several hours going trough all the VS settings trying to figure out why the release build generated linker errors and the debug didn’t.
In addition to your instructions I also had to remove the libcmt.lib from the ignored libraries.
(removed double post)