Note that there are some explanatory texts on larger screens.

plurals
  1. POVC++ Library Clashing Problem
    text
    copied!<p>I am working on a C++ project that uses Qt (gui lib), VTK (graphics lib) and another library which is so obscure I won't mention its name and will instead call it LIB_X. The project uses Qt for the gui components and VTK (more precisely the QVTKWidget extension provided by VTK that supports Qt) for rendering geometry.. and it uses LIB_X to gather and manipulate geometry.</p> <p>The problem is that it turns out that LIB_X actually uses VTK (where and how, I don't know, it's closed source). At first there was no problem, compiling with both libs linked was going fine, but at some point I called a certain (and highly needed) LIB_X function and compiling led to a bunch of 'blah blah something about a VTK lib/obj already defined in LIB_X dll' errors. </p> <p>e.g. (and note this is with /FORCE:MULTIPLE so it's a warning here, let me know if you want the error without /FORCE:MULTIPLE and I'll post it):</p> <pre><code>1&gt;LIB_X.lib(LIB_X.dll) : warning LNK4006: "public: __thiscall std::vector&lt;double,class std::allocator&lt;double&gt; &gt;::~vector&lt;double,class std::allocator&lt;double&gt; &gt;(void)" (??1?$vector@NV?$allocator@N@std@@@std@@QAE@XZ) already defined in vtkCommon.lib(vtkInformationDoubleVectorKey.obj); </code></pre> <p>I tried using /FORCE:MULTIPLE and it seemed to be a miracle at first, but I am getting random errors in code that would mostly give heap errors. I decided to remove all references to LIB_X from the main project and created a static lib that would handle all LIB_X stuff. I'm not a C++ expert, so I'm not certain how it handles lib clashing when you're using a pre-compiled lib, but I still received lib clashing errors when linking my static lib into my main project, so I still have to use /FORCE:MULTIPLE. </p> <p>Once I had the static lib it seemed like the random errors had gone away, I was able to do a lot with LIB_X methods in the main project via the static lib, BUT out of nowhere, I added a new data member to my main project's class (a std::vector of doubles) and suddenly I was getting a heap error in one of my static library's methods. If I commented out the new data member, the static library's method would run fine. I hate to give the current error, because honestly I'm not sure if examining it will be worthwhile, but here it is anyway in case it can help:</p> <p>note: it crashes to xutility on about line 151, pops up assertion: "file: dbgheap.c line: 1279 expression: _CrtIsValidHeapPointer(pUserData)"</p> <p>The error comes after adding a vector vector double to a vector vector vector double, crashing on the push_back line:</p> <pre><code>std::vector&lt;std::vector&lt;double&gt;&gt; tmpVec; for(srvl_iter = srvl.begin(); srvl_iter != srvl.end(); ++srvl_iter) { tmpVec.push_back((*srvl_iter).getControlPoints()); } this-&gt;_splines.push_back(tmpVec); //CRASH </code></pre> <p>It only started crashing here when I added a new data member to my main project (separate from the static lib!) Commenting out the new data member takes the error away.</p> <pre><code>std::vector&lt;std::vector&lt;std::vector&lt;double&gt;&gt;&gt; _geometry; </code></pre> <p>So, /FORCE:MULTIPLE seems bad, I get random errors that just don't make sense to me. Are there other solutions? Am I screwed? Is there something I can do with LIB_X's linking of VTK?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload