[vtkusers] VTK 6.0 with Visual Studio

Biddiscombe, John A. biddisco at cscs.ch
Fri Jul 26 05:18:11 EDT 2013


> I think we need to help customers like Joseph. Can you tell him how to get his code configured?

I had to get a small VTK only demo working and after much pain, I finally discovered that I had to add a definition
vtkRenderingVolume_AUTOINIT=1(vtkRenderingVolumeOpenGL)
to my project to stop it returning NULL pointers from every New call in the rendering code.

This was very painful to discover and the only way I found it was by stepping through the code and grepping everything I could think of.

I suspect that people with less experience than I using VTK have no chance of discovering secret tricks like this on their own and I certainly hope I don't have to do this for every project.

JB

From: vtkusers-bounces at vtk.org [mailto:vtkusers-bounces at vtk.org] On Behalf Of Bill Lorensen
Sent: 24 July 2013 19:55
To: Marcus D. Hanwell
Cc: VTK Users
Subject: Re: [vtkusers] VTK 6.0 with Visual Studio

I don';t have these problems for some reason. I think we need to help customers like Joseph. Can you tell him how to get his code configured?


On Wed, Jul 24, 2013 at 1:41 PM, Marcus D. Hanwell <marcus.hanwell at kitware.com<mailto:marcus.hanwell at kitware.com>> wrote:
Bill,

I can take a look at adding some simpler macros that can be called to
initialize code, we take care of all of the defines if CMake is used
but it is quite difficult to get right when not using CMake. Do you
have specific suggestions on how you want to see this fixed Bill? The
errors output indicate the defines are not being set correctly, and
that is why I added the debug output (to make this issue easier to
spot).

Marcus

On Tue, Jul 23, 2013 at 5:00 PM, Bill Lorensen <bill.lorensen at gmail.com<mailto:bill.lorensen at gmail.com>> wrote:
> Marcus,
>
> The new factory mechanism is frustrating users. Apparently, the current
> documentation is not clear enough. We need to fix this.
>
> Bill
>
>
>
> On Tue, Jul 23, 2013 at 4:57 PM, Bill Lorensen <bill.lorensen at gmail.com<mailto:bill.lorensen at gmail.com>>
> wrote:
>>
>> This is not your fault. It is our (vtk developers) fault.
>>
>>
>>
>> On Tue, Jul 23, 2013 at 4:46 PM, Brooke Steele <bnsteel at gmail.com<mailto:bnsteel at gmail.com>> wrote:
>>>
>>> Well, I'm not a CMake guru.
>>>
>>>  I am not smart enough to figure out how to make CMake include all of my
>>> settings from my existing project, so I emulated the output of using CMake
>>> with VTK6.0 to make a VTK only VS project, and ported what I found to my
>>> existing VS project.
>>>
>>> I couldn't find sufficient description of what I was "supposed" to do
>>> online, so I had to wing it.
>>>
>>>  My project works, so I feel like the manual includes were the right
>>> thing for me.
>>>
>>> Brooke
>>>
>>>
>>> On Tue, Jul 23, 2013 at 3:49 PM, Bill Lorensen <bill.lorensen at gmail.com<mailto:bill.lorensen at gmail.com>>
>>> wrote:
>>>>
>>>> You should not have to manually include any directories in VS.
>>>>
>>>>
>>>>
>>>> On Tue, Jul 23, 2013 at 3:33 PM, Brooke Steele <bnsteel at gmail.com<mailto:bnsteel at gmail.com>>
>>>> wrote:
>>>>>
>>>>> Joseph,
>>>>>
>>>>> I recently was successful in getting VTK6.0 working with my VS2008
>>>>> project.
>>>>>
>>>>> What I had to do was include the headers in BOTH the source
>>>>> distribution AND the CMake build directory. It would build fine with just
>>>>> the source headers, since that is where the definitions are, but it wouldn't
>>>>> run because the macro/module definitions are in the build directory.
>>>>>
>>>>>  There are 50 vtk include directories in my project, half from the
>>>>> source and half from the build.
>>>>>
>>>>> Brooke
>>>>>
>>>>>
>>>>> On Tue, Jul 23, 2013 at 1:55 PM, Joseph Melnyk <JMelnyk at pile.com<mailto:JMelnyk at pile.com>>
>>>>> wrote:
>>>>>>
>>>>>> I built VTK in debug mode and got a bit more information.  The
>>>>>> debugger doesn't trace into VTK, it just outputs the following to the output
>>>>>> console:
>>>>>>         Generic Warning: In
>>>>>> ..\..\..\VTK6.0.0\Rendering\Core\vtkRenderer.cxx, line 47
>>>>>>         Error: no override found for 'vtkRenderer'.
>>>>>>         Generic Warning: In
>>>>>> ..\..\..\VTK6.0.0\Rendering\Core\vtkRenderWindow.cxx, line 35
>>>>>>         Error: no override found for 'vtkRenderWindow'
>>>>>>
>>>>>> Which are the respective lines:
>>>>>>         vtkAbstractObjectFactoryNewMacro(vtkRenderer)
>>>>>>         vtkAbstractObjectFactoryNewMacro(vtkRenderWindow)
>>>>>>
>>>>>> This occurs when I try to execute the following line:
>>>>>>         vtkSmartPointer<vtkContextView> view =
>>>>>> vtkSmartPointer<vtkContextView>::New();
>>>>>>
>>>>>> Note that I am doing the autoinit as follows:
>>>>>>         #define vtkRenderingCore_AUTOINIT
>>>>>> 4(vtkInteractionStyle,vtkRenderingFreeType,vtkRenderingFreeTypeOpenGL,vtkRenderingOpenGL)
>>>>>>         #define vtkRenderingVolume_AUTOINIT
>>>>>> 1(vtkRenderingVolumeOpenGL)
>>>>>>
>>>>>> This is defined within the header file of any class using VTK.
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> From: Bill Lorensen [mailto:bill.lorensen at gmail.com<mailto:bill.lorensen at gmail.com>]
>>>>>> Sent: Tuesday, July 23, 2013 11:35 AM
>>>>>> To: Joseph Melnyk
>>>>>> Cc: Robert Maynard; vtkusers at vtk.org<mailto:vtkusers at vtk.org>
>>>>>> Subject: Re: [vtkusers] VTK 6.0 with Visual Studio
>>>>>>
>>>>>> If you build your VTK Debug you you should see more.
>>>>>>
>>>>>> On Tue, Jul 23, 2013 at 11:24 AM, Joseph Melnyk <JMelnyk at pile.com<mailto:JMelnyk at pile.com>>
>>>>>> wrote:
>>>>>> Thanks for the suggestion.  I can't trace directly into the vtk dll's
>>>>>> for more information.  The stack trace just tells me where they've failed in
>>>>>> the .h file, which is just the New() call.
>>>>>>
>>>>>> As I said, some objects will instantiate and can be used just fine.
>>>>>> For example, I can use vtkTable and vtkFloatArray just fine but then when I
>>>>>> try to use vtkContextView or vtkInteractorStyleTrackballCamera, the New()
>>>>>> event fails.
>>>>>>
>>>>>> Regards
>>>>>> Joseph Melnyk
>>>>>>
>>>>>>
>>>>>>
>>>>>> > -----Original Message-----
>>>>>> > From: Robert Maynard [mailto:robert.maynard at kitware.com<mailto:robert.maynard at kitware.com>]
>>>>>> > Sent: Tuesday, July 23, 2013 9:14 AM
>>>>>> > To: Joseph Melnyk
>>>>>> > Cc: vtkusers at vtk.org<mailto:vtkusers at vtk.org>
>>>>>> > Subject: Re: [vtkusers] VTK 6.0 with Visual Studio
>>>>>> >
>>>>>> > Are you able to provide more information on the exact violation
>>>>>> > exceptions
>>>>>> > with a back trace? Access violations can occur when you call methods
>>>>>> > on a
>>>>>> > NULL object, so it could be a case that a object factory that is
>>>>>> > NULL is being
>>>>>> > asked to create classes.
>>>>>> >
>>>>>> > On Mon, Jul 22, 2013 at 2:45 PM, Joseph Melnyk <JMelnyk at pile.com<mailto:JMelnyk at pile.com>>
>>>>>> > wrote:
>>>>>> > > I'm attempting to port an existing code base from VTK 5.10 to 6.0.
>>>>>> > > This
>>>>>> > code base has existed and worked happily with VTK 5.x for a few
>>>>>> > years now,
>>>>>> > being built with Visual Studio 2008.  When I began the port to 6.0,
>>>>>> > I followed
>>>>>> > the migration guide found here:
>>>>>> > http://www.vtk.org/Wiki/VTK/VTK_6_Migration_Guide and the code
>>>>>> > builds
>>>>>> > and links just fine.  However, when I run it, I'm getting access
>>>>>> > violation
>>>>>> > exceptions (attempts to read/write protected memory) when I try
>>>>>> > instantiating with New().  Researching further, I see that this
>>>>>> > problem is
>>>>>> > mentioned here:
>>>>>> > http://www.vtk.org/Wiki/VTK/VTK_6_Migration/Factories_now_require_de
>>>>>> > fines  HOWEVER I'm not getting NULL objects with the New() call, I'm
>>>>>> > getting
>>>>>> > exceptions.  Furthermore, it doesn't happen with every VTK object;
>>>>>> > some
>>>>>> > instantiate and can be used just fine.  Nonetheless, I tried the
>>>>>> > suggestions at
>>>>>> > the second link, regarding definition of VTK AUTOINIT, and they
>>>>>> > proved
>>>>>> > fruitless.  So I'm currently at a loss...
>>>>>> > >
>>>>>> > > For what it's worth, I'm building VTK with CMAKE and the only
>>>>>> > > options I'm
>>>>>> > changing from the default configuration are the following:
>>>>>> > > - build shared libs
>>>>>> > > - don't build TESTING
>>>>>> > > - set custom install directory
>>>>>> > >
>>>>>> > > Thanks for your time; any help would be greatly appreciated...
>>>>>> > > Joseph Melnyk
>>>>>> > >
>>>>>> > > __Scanned by MessageLabs
>>>>>> > > _______________________________________________
>>>>>> > > Powered by www.kitware.com<http://www.kitware.com>
>>>>>> > >
>>>>>> > > Visit other Kitware open-source projects at
>>>>>> > > http://www.kitware.com/opensource/opensource.html
>>>>>> > >
>>>>>> > > Please keep messages on-topic and check the VTK FAQ at:
>>>>>> > > http://www.vtk.org/Wiki/VTK_FAQ
>>>>>> > >
>>>>>> > > Follow this link to subscribe/unsubscribe:
>>>>>> > > http://www.vtk.org/mailman/listinfo/vtkusers
>>>>>> >
>>>>>> > _Scanned by MessageLabs
>>>>>>
>>>>>> __Scanned by MessageLabs
>>>>>> _______________________________________________
>>>>>> Powered by www.kitware.com<http://www.kitware.com>
>>>>>>
>>>>>> Visit other Kitware open-source projects at
>>>>>> http://www.kitware.com/opensource/opensource.html
>>>>>>
>>>>>> Please keep messages on-topic and check the VTK FAQ at:
>>>>>> http://www.vtk.org/Wiki/VTK_FAQ
>>>>>>
>>>>>> Follow this link to subscribe/unsubscribe:
>>>>>> http://www.vtk.org/mailman/listinfo/vtkusers
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Unpaid intern in BillsBasement at noware dot com
>>>>>>
>>>>>> _Scanned by MessageLabs
>>>>>>
>>>>>> __Scanned by MessageLabs
>>>>>> _______________________________________________
>>>>>> Powered by www.kitware.com<http://www.kitware.com>
>>>>>>
>>>>>> Visit other Kitware open-source projects at
>>>>>> http://www.kitware.com/opensource/opensource.html
>>>>>>
>>>>>> Please keep messages on-topic and check the VTK FAQ at:
>>>>>> http://www.vtk.org/Wiki/VTK_FAQ
>>>>>>
>>>>>> Follow this link to subscribe/unsubscribe:
>>>>>> http://www.vtk.org/mailman/listinfo/vtkusers
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Unpaid intern in BillsBasement at noware dot com
>>>
>>>
>>
>>
>>
>> --
>> Unpaid intern in BillsBasement at noware dot com
>
>
>
>
> --
> Unpaid intern in BillsBasement at noware dot com



--
Unpaid intern in BillsBasement at noware dot com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20130726/1e98adf7/attachment.htm>


More information about the vtkusers mailing list