1. you must have netcdf, hdf5 and minc2 libraries all built on your system before you attempt to use them check You need to have the attached file in your ITK directory and have cmake find_package command to use it http://packages.bic.mni.mcgill.ca/ for source code or binaries of OS of your choice 2. use the file attached and find_package command of cmake IF(USE_MINC2) SET(CMAKE_MODULE_PATH "/home/whatever") FIND_PACKAGE(MINC2) IF (MINC2_FOUND) INCLUDE_DIRECTORIES(${MINC2_INCLUDE_PATH} ${MINC_INCLUDE_PATH} ${HDF5_INCLUDE_PATH} ${NETCDF_INCLUDE_PATH}) ENDIF(MINC2_FOUND) ENDIF(USE_MINC2) On Tue, 2009-04-21 at 13:36 -0400, Geoff Topping wrote: > Hi, > > My second attempt at a CMakeLists.txt from my previous message > contains the line > > TARGET_LINK_LIBRARIES(ImageReadWrite ITKIO ITKIOMINC2 ${MINC2_LIB} > {HDF5_LIB} ${NETCDF_LIB}) > > which didn't work. I modified it to be your suggestion (removing the > ${} parts) but got the same result: missing minc2.h and various things > not declared. > > Thanks, > Geoff > > > Date: Tue, 21 Apr 2009 13:30:13 -0400 > > From: baghdadi@phenogenomics.ca > > To: g_topping@hotmail.com > > CC: insight-users@itk.org > > Subject: Re: [Insight-users] Building ITK Program Using MINC2 IO > Review Code > > > > Try modifying the CMakeList.txt line > > > > TARGET_LINK_LIBRARIES(ImageReadWrite ITKIO) > > > > to > > > > TARGET_LINK_LIBRARIES(ImageReadWrite ITKIO ITKIOMINC2) > > > > reconfigure and make and you should be fine > > > > Leila > > > > On Tue, 2009-04-21 at 13:20 -0400, Geoff Topping wrote: > > > Hi all. > > > > > > I've enabled the MINC2 IO review code and rebuilt ITK. Now I'd > like > > > to actually test this functionality, but am having trouble setting > up > > > the code and CMakeLists.txt necessary to do so. > > > > > > I started with the basic ImageReadWrite example code, and modified > it > > > based on the results of various web searches. A seemingly helpful > > > example is here: > > > > > > http://en.wikibooks.org/wiki/MINC/Tutorials/part2 > > > > > > The result is this code: > > > > > > My current code: > > > > > > ***************************************************** > > > > > > #include "itkImageFileReader.h" > > > #include "itkImageFileWriter.h" > > > #include "itkImage.h" > > > > > > #include "itkImageIOFactory.h" > > > #include "itkMINC2ImageIOFactory.h" > > > #include "itkMINC2ImageIO.h" > > > > > > > > > namespace { > > > typedef float PixelType; > > > const unsigned int Dimension = 3; > > > typedef itk::Image ImageType; > > > > > > typedef itk::ImageFileReader ReaderType; > > > typedef itk::ImageFileWriter WriterType; > > > > > > typedef itk::MINC2ImageIO ImageIOType; > > > } > > > > > > int main(int argc, char ** argv) { > > > // Verify the number of parameters in the command line > > > if ( argc < 3 ) { > > > std::cerr << "Usage: " << std::endl; > > > std::cerr << argv[0] << " inputImageFile outputImageFile " << > > > std::endl; > > > return EXIT_FAILURE; > > > } > > > > > > ReaderType::Pointer reader = ReaderType::New(); > > > ImageIOType::Pointer minc2ImageIO = ImageIOType::New(); > > > reader->SetImageIO( minc2ImageIO ); > > > const char* inputFilename = argv[1]; > > > reader->SetFileName(inputFilename); > > > > > > > > > WriterType::Pointer writer = WriterType::New(); > > > const char* outputFilename = argv[2]; > > > writer->SetFileName(outputFilename); > > > > > > > > > writer->SetInput(reader->GetOutput()); > > > > > > > > > try { > > > writer->Update(); > > > } catch(itk::ExceptionObject & err) { > > > std::cerr << "ExceptionObject caught !" << std::endl; > > > std::cerr << err << std::endl; > > > return EXIT_FAILURE; > > > } > > > > > > return EXIT_SUCCESS; > > > } > > > > > > ****************************************************** > > > > > > I tried building this using my existing CMakeLists.txt that works > for > > > the same code without the minc-related parts... > > > > > > ****************************************************** > > > > > > # This is the root ITK CMakeLists file. > > > CMAKE_MINIMUM_REQUIRED(VERSION 2.4) > > > IF(COMMAND CMAKE_POLICY) > > > CMAKE_POLICY(SET CMP0003 NEW) > > > ENDIF(COMMAND CMAKE_POLICY) > > > > > > > > > # This project is designed to be built outside the Insight source > > > tree. > > > PROJECT(IOExamples) > > > > > > # Find ITK. > > > FIND_PACKAGE(ITK REQUIRED) > > > INCLUDE(${ITK_USE_FILE}) > > > > > > ADD_EXECUTABLE(ImageReadWrite ImageReadWrite.cxx ) > > > TARGET_LINK_LIBRARIES(ImageReadWrite ITKIO) > > > > > > ******************************************************* > > > > > > After re-running ccmake and running make, I got errors about > missing > > > headers: > > > > > > ******************************************************* > > > > > > /work/geoff/itk/iotest > make > > > [100%] Building CXX object > > > CMakeFiles/ImageReadWrite.dir/ImageReadWrite.o > > > In file included from /work/geoff/itk/iotest/ImageReadWrite.cxx:8: > > > > /work/geoff/InsightToolkit-3.12.0/Code/Review/itkMINC2ImageIO.h:37:19: > > > minc2.h: No such file or directory > > > In file included from /work/geoff/itk/iotest/ImageReadWrite.cxx:8: > > > > /work/geoff/InsightToolkit-3.12.0/Code/Review/itkMINC2ImageIO.h:100: > > > error: `midimhandle_t' has not been declared > > > > /work/geoff/InsightToolkit-3.12.0/Code/Review/itkMINC2ImageIO.h:100: > > > error: ISO C++ forbids declaration of `hdims' with no type > > > > /work/geoff/InsightToolkit-3.12.0/Code/Review/itkMINC2ImageIO.h:145: > > > error: `mihandle_t' has not been declared > > > > /work/geoff/InsightToolkit-3.12.0/Code/Review/itkMINC2ImageIO.h:145: > > > error: ISO C++ forbids declaration of `volume' with no type > > > > /work/geoff/InsightToolkit-3.12.0/Code/Review/itkMINC2ImageIO.h:149: > > > error: `mihandle_t' has not been declared > > > > /work/geoff/InsightToolkit-3.12.0/Code/Review/itkMINC2ImageIO.h:149: > > > error: ISO C++ forbids declaration of `volume' with no type > > > make[2]: *** [CMakeFiles/ImageReadWrite.dir/ImageReadWrite.o] > Error 1 > > > make[1]: *** [CMakeFiles/ImageReadWrite.dir/all] Error 2 > > > make: *** [all] Error 2 > > > /work/geoff/itk/iotest > ccmake . > > > > > > **************************************************** > > > > > > So I hit net searched a bit more, and found some promising looking > > > alterations to the previous CMakeLists.txt, starting after the > > > INCLUDE(${ITK_USE_FILE}) line: > > > > > > **************************************************** > > > > > > FIND_PACKAGE(MINC2) > > > INCLUDE_DIRECTORIES(${MINC2_INCLUDE_PATH} ${HDF5_INCLUDE_PATH} > > > ${NETCDF_INCLUDE_PATH}) > > > > > > ADD_EXECUTABLE(ImageReadWrite ImageReadWrite.cxx ) > > > TARGET_LINK_LIBRARIES(ImageReadWrite ITKIO ITKIOMINC2 ${MINC2_LIB} > > > ${HDF5_LIB} ${NETCDF_LIB}) > > > > > > ***************************************************** > > > > > > After doing this, when I run ccmake, I have an extra line where I > need > > > to enter the location of MINC2_DIR. I give it the same directory > as I > > > used to build ITK after turning on MINC and related options, but > after > > > pressing c to configure, I get an error message: > > > > > > CMake Error: MINC2_DIR is set to "/opt/minc2", which is not a > > > directory containing MINC2Config.cmake > > > > > > I've searched for a file by that name in my ITK binary or code > > > directories. > > > > > > I also tried without the FIND_PACKAGE(MINC2) line, but just got > the > > > same missing headers error during compiling. > > > > > > I don't know how else to point ccmake to the location of the minc2 > > > headers. Can someone suggest what modifications need to be made to > > > CMakeLists.txt so the compiler can find the necessary headers to > build > > > a program using the MINC ITK IO classes, or whatever else I need > to be > > > doing? Is this documented somewhere I haven't found? > > > > > > Thanks, > > > Geoff Topping > > > > > > > > > > > > > > > > ______________________________________________________________________ > > > Windows Live Messenger makes it easier to stay in touch - learn > how! > > > _____________________________________ > > > Powered by 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 ITK FAQ at: > http://www.itk.org/Wiki/ITK_FAQ > > > > > > Follow this link to subscribe/unsubscribe: > > > http://www.itk.org/mailman/listinfo/insight-users > > > > > ______________________________________________________________________ > Messenger has tons of new features that make chatting more fun. Click > here to learn more.