[Insight-users] Compiling ITK on Windows

Luis Ibanez luis.ibanez@kitware.com
Tue, 04 Mar 2003 13:51:21 -0500


This is a multi-part message in MIME format.
--------------010904000609040200000505
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit



Hi Raghavendra,


I just tryied your code in Visual Studio 7
and compiles and links without problem.


One important thing ! that you are doing:


     " using namespace std; "


Please NEVER EVER do this.

by opening the namespace, you are
destroying the whole purpose of
namespaces.

This put you again in the position
where names can be conflicting with
other libraries.

Please find attached the CMakeLists.txt
and source file with the modifications
for the namespaces.


Please let us know if you find
further problems


Thanks


   Luis




-------------------------------------------

Raghavendra Chandrashekara wrote:
> 
> Okay I tried this but unfortunately it didn't work. I also checked the
> project properties in VS.NET. These are the linker options which are being
> used:
> 
> /OUT:"Debug\ITKGIPLImageTest.exe" /INCREMENTAL:NO /NOLOGO
> /LIBPATH:"I:\packages\InsightCVS\Windows\VS.NET\bin\.\Debug"
> /LIBPATH:"I:\packages\InsightCVS\Windows\VS.NET\bin\\" /DEBUG
> /PDB:"Debug\ITKGIPLImageTest.pdb" /SUBSYSTEM:CONSOLE /STACK:10000000
> odbc32.lib odbccp32.lib ITKIO.lib ITKCommon.lib ITKMetaIO.lib
> VXLNumerics.lib itkpng.lib itkzlib.lib ITKDICOMParser.lib   kernel32.lib
> user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib
> ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib
> 
> Looks like the correct path is set, and the libraries are being linked.
> 

--------------010904000609040200000505
Content-Type: text/plain;
 name="CMakeLists.txt"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="CMakeLists.txt"

PROJECT(ITKGIPLImageTest)

INCLUDE(${CMAKE_ROOT}/Modules/FindITK.cmake)
IF (USE_ITK_FILE)
	INCLUDE(${USE_ITK_FILE})
ENDIF (USE_ITK_FILE)

ADD_EXECUTABLE(ITKGIPLImageTest ITKGIPLImageTest.cxx)

IF (WIN32)
	TARGET_LINK_LIBRARIES(ITKGIPLImageTest ITKIO ITKCommon ITKMetaIO VXLNumerics)
ELSE (WIN32)
	TARGET_LINK_LIBRARIES(ITKGIPLImageTest ITKIO ITKCommon ITKMetaIO VXLNumerics dl pthread)
ENDIF (WIN32)
--------------010904000609040200000505
Content-Type: text/plain;
 name="ITKGIPLImageTest.cxx"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="ITKGIPLImageTest.cxx"

#include <iostream>

#include "itkImage.h"
#include "itkImageFileReader.h"
#include "itkImageFileWriter.h"

/* Program reads a GIPl image and writes it out again. */
int main(int argc, char** argv)
{
  if (argc != 3) {
	std::cout << "Usage: ITKGIPLImageTest input.gipl output.gipl" << std::endl;
    exit(1);
  }

  typedef short PixelType;
  typedef itk::Image<PixelType, 3> ImageType;
  typedef itk::ImageFileReader<ImageType> ReaderType;
  typedef itk::ImageFileWriter<ImageType> WriterType;

  try {
    ReaderType::Pointer pReader = ReaderType::New();
    WriterType::Pointer pWriter = WriterType::New();

    pReader->SetFileName(argv[1]);
    pWriter->SetFileName(argv[2]);

    pWriter->SetInput(pReader->GetOutput());

    pWriter->Update();
  }
  catch (itk::ExceptionObject& ex) {
	std::cout << "Exception object caught!" << std::endl;
	std::cout << ex << std::endl;
    exit(1);
  }

  return 0;
}
--------------010904000609040200000505--