[vtk-developers] NULL always returned from vtkPolyDataMapper::New()

Kyle Lutz kyle.lutz at kitware.com
Mon Nov 12 16:22:35 EST 2012


Well, I guess I figured it out. My CMakeLists now looks like this:

find_package(VTK REQUIRED)
include_directories(${VTK_INCLUDE_DIRS})
include(${VTK_USE_FILE})

add_executable(test main.cpp)
target_link_libraries(test vtkRenderingCore vtkInteractionStyle
vtkRenderingFreeTypeOpenGL vtkRenderingOpenGL)

Thanks for your help guys!

-kyle

On Mon, Nov 12, 2012 at 1:20 PM, Kyle Lutz <kyle.lutz at kitware.com> wrote:
> After adding "include(${VTK_USE_FILE})" right after
> "include_directories(${VTK_INCLUDE_DIRS})" I now get the following
> linker errors:
>
> CMakeFiles/test.dir/main.cpp.o: In function `vtkRenderingCore_AutoInit':
> /home/kyle/VTK/build/Rendering/Core/vtkRenderingCoreModule.h:44:
> undefined reference to `vtkInteractionStyle_AutoInit_Construct()'
> /home/kyle/VTK/build/Rendering/Core/vtkRenderingCoreModule.h:44:
> undefined reference to
> `vtkRenderingFreeTypeOpenGL_AutoInit_Construct()'
> /home/kyle/VTK/build/Rendering/Core/vtkRenderingCoreModule.h:44:
> undefined reference to `vtkRenderingOpenGL_AutoInit_Construct()'
> CMakeFiles/test.dir/main.cpp.o: In function `~vtkRenderingCore_AutoInit':
> /home/kyle/VTK/build/Rendering/Core/vtkRenderingCoreModule.h:44:
> undefined reference to `vtkInteractionStyle_AutoInit_Destruct()'
> /home/kyle/VTK/build/Rendering/Core/vtkRenderingCoreModule.h:44:
> undefined reference to
> `vtkRenderingFreeTypeOpenGL_AutoInit_Destruct()'
> /home/kyle/VTK/build/Rendering/Core/vtkRenderingCoreModule.h:44:
> undefined reference to `vtkRenderingOpenGL_AutoInit_Destruct()'
> collect2: ld returned 1 exit status
>
> :-(. Any other ideas?
>
> -kyle
>
> On Mon, Nov 12, 2012 at 1:16 PM, David Doria <daviddoria at gmail.com> wrote:
>> On Mon, Nov 12, 2012 at 4:09 PM, Kyle Lutz <kyle.lutz at kitware.com> wrote:
>>>
>>> Hello everyone,
>>>
>>> I'm trying to write a small reproducible test case for a bug I'm
>>> working on but I can't even get a simple visualization pipeline
>>> running. When I try to create a vtkPolyDataMapper I always get NULL
>>> returned. I've looked through the wiki and at the VTK6 migration guide
>>> but can't find anything related to what I'm seeing.
>>>
>>> I'm sure I'm doing something wrong but I can't seem to figure out:
>>>
>>> === main.cpp ===
>>> #include <cassert>
>>> #include <vtkPolyDataMapper.h>
>>>
>>> int main()
>>> {
>>>   vtkPolyDataMapper *mapper = vtkPolyDataMapper::New();
>>>   assert(mapper != 0);
>>>   return 0;
>>> }
>>>
>>> === CMakeLists.txt ===
>>> find_package(VTK REQUIRED)
>>> include_directories(${VTK_INCLUDE_DIRS})
>>>
>>> add_executable(test main.cpp)
>>> target_link_libraries(test vtkRenderingCore)
>>>
>>> Platform: Ubuntu Linux, 64-bit, GCC 4.6.3, VTK from gerrit/master (as
>>> of this morning)
>>>
>>> I've also tried changing the link line to ${VTK_LIBRARIES} (which
>>> gives the same assertion error) and vtkHybrid (which gives a
>>> "-lvtkHybrid" not found error when linking).
>>>
>>> Any help would be greatly appreciated.
>>>
>>> Thanks,
>>> Kyle
>>
>>
>> I don't know if this would cause the problem, but a line I always use
>> and that is absent in your CMakeLists.txt is:
>>
>> include(${VTK_USE_FILE})
>>
>> David



More information about the vtk-developers mailing list