<div dir="ltr"><br><div class="gmail_quote"><br><br><br><div dir="ltr"><div><div>Hi,<br><br></div>I have the previous working fine code when I used VTK 5.6.1+ITK 3.20.1, but I got lots of problem when I wanted to reuse the code while upgrading to the new VTK/ITK version.<br><br></div><div>My environment, Ubuntu 12.04, CMake 2.8.12.2, VTK 6.1, ITK 4.7. ItkVtkGlue is turned ON.<br></div><div><br></div>The CMakeLists.txt is as the following, I checked the example,<br><br>cmake_minimum_required(VERSION 2.8)<br> <br>PROJECT(BackProjection)<br><br>FIND_PACKAGE(ITK REQUIRED)<br>INCLUDE(${ITK_USE_FILE})<br><br>if (ITKVtkGlue_LOADED)<br>  find_package(VTK REQUIRED)<br>  include(${VTK_USE_FILE})<br>else()<br>  find_package(ItkVtkGlue REQUIRED)<br>  include(${ItkVtkGlue_USE_FILE})<br>  set(Glue ItkVtkGlue)<br>endif()<br>add_executable(ReadPLY MACOSX_BUNDLE ReadPLY.cxx)<br>target_link_libraries(ReadPLY ${Glue} ${VTK_LIBRARIES} ${ITK_LIBRARIES})<br><br><div><div>###<br><br></div><div>When I build with make, the error is,<br><br>[100%] Building CXX object CMakeFiles/ReadPLY.dir/ReadPLY.cxx.o<br>Linking CXX executable ReadPLY<br>CMakeFiles/ReadPLY.dir/ReadPLY.cxx.o: In function `vtkSmartPointer<vtkPLYReader>::New()':<br>ReadPLY.cxx:(.text._ZN15vtkSmartPointerI12vtkPLYReaderE3NewEv[_ZN15vtkSmartPointerI12vtkPLYReaderE3NewEv]+0xd): undefined reference to `vtkPLYReader::New()'<br>collect2: error: ld returned 1 exit status<br>make[2]: *** [ReadPLY] Error 1<br>make[1]: *** [CMakeFiles/ReadPLY.dir/all] Error 2<br>make: *** [all] Error 2<br><br></div><div>Interestingly, when I fully remove anything about ITK in my CMakeLists.txt, it doesn't show any error. So I suspect it is the ITK's build macro which is breaking my VTK code compiling.<br></div><div>The working CMakeLists.txt is like,<br><br>cmake_minimum_required(VERSION 2.8)<br> <br>PROJECT(ReadPLY)<br> <br>find_package(VTK REQUIRED)<br>include(${VTK_USE_FILE})<br> <br>add_executable(ReadPLY MACOSX_BUNDLE ReadPLY.cxx)<br> <br>if(VTK_LIBRARIES)<br>  target_link_libraries(ReadPLY ${VTK_LIBRARIES})<br>else()<br>  target_link_libraries(ReadPLY vtkHybrid vtkWidgets)<br>endif()<br></div><div><br><br>####<br><br>And the ReadPLY.cxx source code is, it is actually a VTK example, doesn't contain any ITK code. But I have the other source code file has ITK code, presenting this example just to show the problem.<br><br>#include <vtkPolyData.h><br>#include <vtkPLYReader.h><br>#include <vtkSmartPointer.h><br>#include <vtkPolyDataMapper.h><br>#include <vtkActor.h><br>#include <vtkRenderWindow.h><br>#include <vtkRenderer.h><br>#include <vtkRenderWindowInteractor.h><br> <br>int main ( int argc, char *argv[] )<br>{<br>  if(argc != 2)<br>    {<br>    std::cout << "Usage: " << argv[0] << "  Filename(.ply)" << std::endl;<br>    return EXIT_FAILURE;<br>    }<br> <br>  std::string inputFilename = argv[1];<br> <br>  vtkSmartPointer<vtkPLYReader> reader =<br>    vtkSmartPointer<vtkPLYReader>::New();<br>  reader->SetFileName ( inputFilename.c_str() );<br> <br>  // Visualize<br>  vtkSmartPointer<vtkPolyDataMapper> mapper =<br>    vtkSmartPointer<vtkPolyDataMapper>::New();<br>  mapper->SetInputConnection(reader->GetOutputPort());<br> <br>  vtkSmartPointer<vtkActor> actor =<br>    vtkSmartPointer<vtkActor>::New();<br>  actor->SetMapper(mapper);<br> <br>  vtkSmartPointer<vtkRenderer> renderer =<br>    vtkSmartPointer<vtkRenderer>::New();<br>  vtkSmartPointer<vtkRenderWindow> renderWindow =<br>    vtkSmartPointer<vtkRenderWindow>::New();<br>  renderWindow->AddRenderer(renderer);<br>  vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =<br>    vtkSmartPointer<vtkRenderWindowInteractor>::New();<br>  renderWindowInteractor->SetRenderWindow(renderWindow);<br> <br>  renderer->AddActor(actor);<br>  renderer->SetBackground(0.1804,0.5451,0.3412); // Sea green<br> <br>  renderWindow->Render();<br>  renderWindowInteractor->Start();<br> <br>  return EXIT_SUCCESS;<br>}<br><br>####<br></div></div></div>
</div><br></div>