[vtkusers] VTK 6.1 linking/autoinit

Marcus D. Hanwell marcus.hanwell at kitware.com
Tue Sep 10 13:17:00 EDT 2013


On Mon, Sep 9, 2013 at 11:42 AM, David Cole <dlrdave at aol.com> wrote:
>> I’ve been using VTK 6.0 libs with
>>
>> #define
>
> vtkRenderingCore_AUTOINIT4(vtkInteractionStyle,vtkRenderingFreeType,vtkRe
> nderingFreeTypeOpenGL,vtkRenderingOpenGL)
>>
>> #define vtkRenderingVolume_AUTOINIT1(vtkRenderingVolumeOpenGL)
>>
>> I was just putting together a test project and decided to try the 6.1
>
> libs and with the above mentioned defines
>>
>> I get several linker errors related to vtkRenderingOpenGL-6.1.lib ...
>
> What linker errors do you get?
>
> Do you put those #define lines before *every* VTK header file? (i.e. -- if
> you have some cpp files where you do and some where you don't, then there
> could be link time inconsistencies that would cause linker errors...)
>
I had been meaning to add something like this for a while, but if you
take a look at,

http://review.source.kitware.com/#/t/3229/

It adds a new macro where you can individually initialize modules, so
that the order stuff no longer matters and you just need a source file
in your executable with the init calls, it is as simple as adding a
C++ source to your project with something like,

#include "vtkAutoInit.h"

VTK_MODULE_INIT(vtkRenderingOpenGL);
VTK_MODULE_INIT(vtkRenderingVolumeOpenGL);

Due to the way they are initialized it won't break things if it should
end up being done more than once. I have asked Brad to check over the
macro code, you could effectively copy the snippet into your project
(adjusting the macro name to avoid conflicts once this is merged) if
you want to use it with older versions of VTK too. It is the
simplified version of what autoinit does when you don't want the build
system to take care of everything for you (the original goal of
autoinit).

Marcus



More information about the vtkusers mailing list