[vtkusers] VTK 6.0 static New() function returns NULL
Marcus D. Hanwell
marcus.hanwell at kitware.com
Thu Apr 18 12:16:42 EDT 2013
On Thu, Apr 18, 2013 at 12:01 PM, David Cole <dlrdave at aol.com> wrote:
> This has come up several times recently, for example, last month in this
> thread:
>
> http://www.vtk.org/pipermail/vtkusers/2013-March/127811.html
>
> (Follow that whole thread through to see some suggestions about how to make
> this work for a non-CMake based project right now.)
>
> Or take a look at this commit in VTK/Examples, that shows how to build an
> Xcode project against VTK 6:
>
>
> https://github.com/Kitware/VTK/commit/9385718b82e6af83b7e7dcc90a937419edc6892b
>
> Perhaps we (the VTK community) ought to consider providing a
> configured/installed header file that provides the auto init defines rather
> than stuffing them into CMake properties... Apparently, there are several
> real-world VTK clients who do not use CMake to drive their projects.
We did consider this when porting code. We could configure a header
that would initialize all implementation modules, but then you would
get symbol not found errors for the things you didn't actually want to
link to. I guess people could use that as a starting point, it would
also be pretty simple to add a macro that could be called to
initialize a named module but that would be a manual step.
>
> If the defines were in a centrally included VTK header file, then anybody
> including the header would get the defines, regardless of whether they use
> CMake to drive their build or not. Wouldn't it be better if that were
> automatic, and people didn't run into this problem? (i.e. -- it would be
> easy to turn this into a non-issue...)
>
When we looked at this we explored several alternatives, but given the
constraints there isn't an automatic in all circumstances way of
initializing the modules. It wouldn't take much to add a configured
header that initialized all implementation modules, but your code
would then be forced to link to everything or you hand edit that
header after. We could use static variables to initialize the
factories, and push this registration mechanism to static builds where
you must make a call to initialize the module's factories.
Chris, Brad and I spent several days thinking of simple solutions. If
the implementation modules were loaded as plugins things would be
simpler, and you could special case static plugins as many projects
(including Qt) do.
Marcus
More information about the vtkusers
mailing list