[ITK] [ITK-users] [ITK-dev] Probelm building project with VTK 6.1 + ITK 4.7
Bill Lorensen
bill.lorensen at gmail.com
Mon Feb 2 08:34:50 EST 2015
What you have should work. I just built this example:
http://itk.org/Wiki/ITK/Examples/Smoothing/MedianImageFilter
no problems. Can you try the same example?
On Mon, Feb 2, 2015 at 2:08 AM, Jianming <jianming.tom at gmail.com> wrote:
>
>
>
>
> Hi,
>
> 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.
>
> My environment, Ubuntu 12.04, CMake 2.8.12.2, VTK 6.1, ITK 4.7. ItkVtkGlue
> is turned ON.
>
> The CMakeLists.txt is as the following, I checked the example,
>
> cmake_minimum_required(VERSION 2.8)
>
> PROJECT(BackProjection)
>
> FIND_PACKAGE(ITK REQUIRED)
> INCLUDE(${ITK_USE_FILE})
>
> if (ITKVtkGlue_LOADED)
> find_package(VTK REQUIRED)
> include(${VTK_USE_FILE})
> else()
> find_package(ItkVtkGlue REQUIRED)
> include(${ItkVtkGlue_USE_FILE})
> set(Glue ItkVtkGlue)
> endif()
> add_executable(ReadPLY MACOSX_BUNDLE ReadPLY.cxx)
> target_link_libraries(ReadPLY ${Glue} ${VTK_LIBRARIES} ${ITK_LIBRARIES})
>
> ###
>
> When I build with make, the error is,
>
> [100%] Building CXX object CMakeFiles/ReadPLY.dir/ReadPLY.cxx.o
> Linking CXX executable ReadPLY
> CMakeFiles/ReadPLY.dir/ReadPLY.cxx.o: In function
> `vtkSmartPointer<vtkPLYReader>::New()':
> ReadPLY.cxx:(.text._ZN15vtkSmartPointerI12vtkPLYReaderE3NewEv[_ZN15vtkSmartPointerI12vtkPLYReaderE3NewEv]+0xd):
> undefined reference to `vtkPLYReader::New()'
> collect2: error: ld returned 1 exit status
> make[2]: *** [ReadPLY] Error 1
> make[1]: *** [CMakeFiles/ReadPLY.dir/all] Error 2
> make: *** [all] Error 2
>
> 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.
> The working CMakeLists.txt is like,
>
> cmake_minimum_required(VERSION 2.8)
>
> PROJECT(ReadPLY)
>
> find_package(VTK REQUIRED)
> include(${VTK_USE_FILE})
>
> add_executable(ReadPLY MACOSX_BUNDLE ReadPLY.cxx)
>
> if(VTK_LIBRARIES)
> target_link_libraries(ReadPLY ${VTK_LIBRARIES})
> else()
> target_link_libraries(ReadPLY vtkHybrid vtkWidgets)
> endif()
>
>
> ####
>
> 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.
>
> #include <vtkPolyData.h>
> #include <vtkPLYReader.h>
> #include <vtkSmartPointer.h>
> #include <vtkPolyDataMapper.h>
> #include <vtkActor.h>
> #include <vtkRenderWindow.h>
> #include <vtkRenderer.h>
> #include <vtkRenderWindowInteractor.h>
>
> int main ( int argc, char *argv[] )
> {
> if(argc != 2)
> {
> std::cout << "Usage: " << argv[0] << " Filename(.ply)" << std::endl;
> return EXIT_FAILURE;
> }
>
> std::string inputFilename = argv[1];
>
> vtkSmartPointer<vtkPLYReader> reader =
> vtkSmartPointer<vtkPLYReader>::New();
> reader->SetFileName ( inputFilename.c_str() );
>
> // Visualize
> vtkSmartPointer<vtkPolyDataMapper> mapper =
> vtkSmartPointer<vtkPolyDataMapper>::New();
> mapper->SetInputConnection(reader->GetOutputPort());
>
> vtkSmartPointer<vtkActor> actor =
> vtkSmartPointer<vtkActor>::New();
> actor->SetMapper(mapper);
>
> vtkSmartPointer<vtkRenderer> renderer =
> vtkSmartPointer<vtkRenderer>::New();
> vtkSmartPointer<vtkRenderWindow> renderWindow =
> vtkSmartPointer<vtkRenderWindow>::New();
> renderWindow->AddRenderer(renderer);
> vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =
> vtkSmartPointer<vtkRenderWindowInteractor>::New();
> renderWindowInteractor->SetRenderWindow(renderWindow);
>
> renderer->AddActor(actor);
> renderer->SetBackground(0.1804,0.5451,0.3412); // Sea green
>
> renderWindow->Render();
> renderWindowInteractor->Start();
>
> return EXIT_SUCCESS;
> }
>
> ####
>
>
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.php
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/insight-users
>
--
Unpaid intern in BillsBasement at noware dot com
_____________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Kitware offers ITK Training Courses, for more information visit:
http://www.kitware.com/products/protraining.php
Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ
Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/insight-users
More information about the Community
mailing list