[ITK-users] ITK3.20.2 Crashes - Help!

Khojaste, Amir amir.khojaste at sunnybrook.ca
Thu Apr 30 11:36:00 EDT 2015


Hey guys,

Could anyone please help me with this?!

I am really confused! I can't run a simple Image Reading code with ITK. I have built ITK Examples and ran their code and it went fine! But I can't run my own code!

Is my CMakelists.txt correct? I have built ITK3.20.2 in Debug mode with VS2008 and added the CMake_Install_Prefix directory to my project. It seems that all the correct ITK libraries and headers are there but I am guessing maybe my CMakelists.txt is not correct. Any help?!

Thanks,
Amir

From: Insight-users [mailto:insight-users-bounces at itk.org] On Behalf Of Khojaste, Amir
Sent: April-29-15 12:36 PM
To: insight-users at itk.org
Subject: [ITK-users] ITK3.20.2 Crashes - Help!

Hi guys,

I am running the simplest piece of code using ITK3.20.2 libraries. In my program I simply want to read an image and do some processing on it and then save it. When I try to instantiate a pointer to my ImageFileReader the program crashes with the following message:

Unhandled exception at 0x000000013fbcf0b1 in HelloWorld.exe: 0xC0000005: Access violation reading location 0x00000000bfdef6f5.

It seems to be a memory leak error or something. I have used ITK3.20.2, CMake 2.8.10.2 and Visual Studio 2008 to configure my project. Following please find my code and my CMakelists.txt:

/* Code ===========================================================================================*/
#include "itkImage.h"
#include <iostream>
#include "itkImageFileWriter.h"
#include "itkImageFileReader.h"
#include "itkCropImageFilter.h"
#include "itksys/SystemTools.hxx"

const unsigned int ImageDimensions = 3;

typedef itk::Vector<signed short, 1>       VectorType;
typedef itk::Image<VectorType, ImageDimensions> ImageType;

typedef itk::Image<VectorType, 2 >  ImageType2D;
typedef itk::ImageFileReader<ImageType> ReaderType;

int main(int argc, char* argv[])
{

  ImageType::Pointer image = ImageType::New(); //--- This line seem to be OK!

  ReaderType::Pointer reader = ReaderType::New(); //--This line will crash!

      system("pause");

      return EXIT_SUCCESS;
}

/* CMakelists.txt ===========================================================================================*/
# This is the root ITK CMakeLists file.
cmake_minimum_required(VERSION 2.4)
if(COMMAND CMAKE_POLICY)
  cmake_policy(SET CMP0003 NEW)
endif()


# This project is designed to be built outside the Insight source tree.
project(HelloWorld)

# Find ITK.
find_package(ITK REQUIRED)
include(${ITK_USE_FILE})

add_executable(HelloWorld HelloWorld.cxx )

target_link_libraries(HelloWorld ${ITK_LIBRARIES})


I have tried this using Visual Studio 2013, ITK 4.7 and CMake 3.1.3 and it ran just fine! But here it doesn't!

Any Idea on what might be the cause of problem? I am confused ...


Thanks,
Amir

This e-mail is intended only for the named recipient(s) and may contain confidential, personal and/or health information (information which may be subject to legal restrictions on use, retention and/or disclosure).  No waiver of confidence is intended by virtue of communication via the internet.  Any review or distribution by anyone other than the person(s) for whom it was originally intended is strictly prohibited.  If you have received this e-mail in error, please contact the sender and destroy all copies.

This e-mail is intended only for the named recipient(s) and may contain confidential, personal and/or health information (information which may be subject to legal restrictions on use, retention and/or disclosure).  No waiver of confidence is intended by virtue of communication via the internet.  Any review or distribution by anyone other than the person(s) for whom it was originally intended is strictly prohibited.  If you have received this e-mail in error, please contact the sender and destroy all copies.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/insight-users/attachments/20150430/0f16734f/attachment.html>


More information about the Insight-users mailing list