[ITK] [ITK-users] [ITK-dev] Probelm building project with VTK 6.1 + ITK 4.7
Matt McCormick
matt.mccormick at kitware.com
Mon Feb 2 21:47:12 EST 2015
Hi,
I thought this patch [1] had been merged, but after re-checking it is
not yet in VTK master. If you test against this branch, you may be
able to verify that it fixes your issue.
Thanks,
Matt
[1] http://review.source.kitware.com/#/t/5170/
On Mon, Feb 2, 2015 at 9:15 PM, Jianming <jianming.tom at gmail.com> wrote:
> @Bill, the compiling of the the normal ITK examples are fine for me here. It
> just when it links the ITK and VTK together problem happens.
>
> @Matt, I will test it once I have the time.
>
> I kind of did a workaround, since I just need the VXL in ITK code, so I gave
> up linking ITK, but used the following CMakeLists.txt
>
> cmake_minimum_required(VERSION 2.8)
>
> PROJECT(BackProjection)
>
> find_package(VTK REQUIRED)
> include(${VTK_USE_FILE})
>
> FIND_PACKAGE( OpenCV REQUIRED )
> INCLUDE_DIRECTORIES(${OPENCV_INCLUDE_DIR})
>
> FIND_PACKAGE(VXL REQUIRED)
> INCLUDE(${VXL_CMAKE_DIR}/UseVXL.cmake)
>
> SET(CMAKE_CXX_FLAGS "-g -O2 -fopenmp")
>
> add_executable(BackProjection MACOSX_BUNDLE BackProjection)
> add_executable(deviation MACOSX_BUNDLE deviation)
> add_executable(imageviewer MACOSX_BUNDLE imageviewer)
> add_executable(deviation_autopipeline MACOSX_BUNDLE deviation_autopipeline)
> add_executable(ReadPLY MACOSX_BUNDLE ReadPLY.cxx)
>
> target_link_libraries(ReadPLY ${VTK_LIBRARIES} )
> target_link_libraries(BackProjection vnl vnl_algo ${VTK_LIBRARIES}
> ${OpenCV_LIBS})
> target_link_libraries(deviation ${OpenCV_LIBS})
> target_link_libraries(imageviewer ${OpenCV_LIBS})
> target_link_libraries(deviation_autopipeline ${OpenCV_LIBS})
>
> On 2 February 2015 at 21:48, Matt McCormick <matt.mccormick at kitware.com>
> wrote:
>>
>> Hi Jianming,
>>
>> Could you please also try VTK Git master and report your results?
>>
>> Thanks,
>> Matt
>>
>> On Mon, Feb 2, 2015 at 8:34 AM, Bill Lorensen <bill.lorensen at gmail.com>
>> wrote:
>> > 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
>
>
_____________________________________
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