Dear All,
I moved this question from my email to insight-users@itk.org to this forum as suggested by Dženan. The original content (sent to insight-users@itk.org) was copied below. Dženan asked whether I used CMake to configure the compiler for the read-image-file code.
I used the following CMake file and set ITK_DIR in ccmake to /path/to/ITK-build-release with the same compilation setting as the compiler setting for building the ITK library with
CMAKE_CXX_COMPILER /usr/lib64/ccache/c++
CMAKE_CXX_FLAGS -std=c++11 -pthread
CMAKE_EXE_LINKER_FLAGS -pthread
After configuring and generating using ccmake, I call ‘make’ to compile and build the code.
Would anyone know why I get this error or how could I fix this error?
Thank you very much for your time and help
Best regads,
Ja
#- CMake file
cmake_minimum_required(VERSION 2.8)
project(read_image)
find_package(ITK REQUIRED)
include(${ITK_USE_FILE})
add_executable(test_read_image test_read_image.cxx)
target_link_libraries(test_read_image ${ITK_LIBRARIES})
#-Content in the original email
I have a problem compiling a simple read-image-file code below in Fedora, after I build ITK 4.12.1 from source code downloaded from the ITK website. I did not receive any error for compiling ITK. For compilation of ITK 4.12.1, I did not change the default CMake options of the ITK library, and the CMake options for compilation were set as
CMAKE_CXX_COMPILER /usr/lib64/ccache/c++
CMAKE_CXX_FLAGS -std=c++11 -pthread
CMAKE_EXE_LINKER_FLAGS -pthread
The error, from compiling the read-image-file code below, was all “undefined reference to ‘vnl_vector::~vnl_vector()’” with some data types T including long long, short, unsigned char, etc. I attached the file containing the error (std::cerr from ‘make’ command for single-thread compilation) to this email.
// Code
#include “itkImageFileReader.h”
int main()
{
typedef itk::Image<float, 2> ImageType;
typedef itk::ImageFileReader ImageFileReaderType;
ImageFileReaderType::Pointer reader = ImageFileReaderType::New();
reader->SetFileName(“some_image_filename”);
reader->Update();
ImageType::Pointer image = reader->GetOutput();
return EXIT_SUCCESS;
}