[vtkusers] Using static VTK library in a DLL
David Cole
david.cole at kitware.com
Thu Nov 29 17:35:48 EST 2007
Do you access VTK objects from one single executable or from an exe and one
or more dlls...?
If you access VTK objects from multiple binaries, and pass them between
binary components, you *must* use dlls for VTK. Otherwise, there will be
multiple values for vtkTimeStamp's counter and modified time comparisons
will not work from dll to dll (because they have each linked in a static
copy of the data for the vtkTimeStamp counter.)
(And there are probably other things are likely to be set up incorrectly as
well, as evidenced by the output in your original question...)
HTH,
David
On 11/12/07, Xavi Planes <Xavier.Planes at upf.edu> wrote:
>
> Hi,
>
>
>
> I'm using VTK libraries, for compiling and linking my own code. I use a
> DLL library and an application program to test it. The application program
> does this:
>
> 1. Loads a vtkPolyData using vtkPolyDataReader.
>
> 2. Calls the function SetData(vtkPolyData *pData ) on an object inside the
> DLL. The pData pointer is copied into an internal pointer m_pData and calls
> Register( ) function of the pData.
>
> 3. Destroy the vtkPolyDataReader: ptrVtkReader->Delete();
>
> 4. Call function Initialize() of the object inside the DLL. This function
> uses the vtkPolyData stored into the internal pointer m_pData, creates a
> vtkThreshold filter, calls SetInput() and calls Update().
>
>
>
> If I use VTK libraries compiled in dynamic mode, there's no problem and
> everything is working fine.
>
> However, if I use VTK libraries compiled in static mode, the vtkThreshold
> raises this error:
>
> "vtkStreamDemandDrivenPipeline: Input for connection index 0 on input port
> index 0 for algorithm vtkThreshold is NULL, but a vtkDataSet is required. "
>
>
>
> If I debug the program, I can see that the input passed to the
> vtkThreshold is right and different from NULL.
>
>
>
> So, my question is: Could somebody give me a clue about what is going
> wrong and how to solve it, please? For example, is there an object that
> takes care of memory management and is given me problems (a singleton class
> managing memory and there is an instance in the executable and another in
> the DLL when VTK is static)?
>
>
>
> Thanks,
>
> Xavi
>
>
>
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20071129/db7a1b7a/attachment.htm>
More information about the vtkusers
mailing list