-2

I tried to compile a simple helloWord C++ program with cmake using the ITK library. However I have some difficulties to link with the ITK library and my program doesn't work.

I put my program in the attachment. helloWorld programme

CMakeLists.txt :

project(HelloWorld)

find_package(ITK REQUIRED)
include(${ITK_USE_FILE})

add_executable(HelloWorld HelloWorld.cxx)

target_link_libraries(HelloWorld ${ITK_LIBRAIRIES})

HelloWorld.cxx :

#include "itkImage.h"
#include <iostream>

int main()
{

  typedef itk::Image< unsigned short, 3 >  ImageType;

  ImageType::Pointer image = ImageType::New();

  std::cout  <<"ITK Hello World !"<< std::endl;

  return 0 ;

} 
axel
  • 77
  • 1
  • 9
  • 1
    You should put the error in the question, and possibly some of the most interesting lines of code. – SwiftArchitect Aug 06 '15 at 08:53
  • The error message is very long and I don't know where is located the mistake. That why I share the project with the CMakeLists.txt sorry ! – axel Aug 06 '15 at 10:30
  • 1
    Put at least the code of the cmakeLists.txt and some clue about the error. I (and I guess many other) try to answerto a clear question... if it doesn't involve downloading external stuff and try to build things on my system (and maybe the problem is in your environment anyway, impossible to say without error) – lib Aug 06 '15 at 10:35
  • Or, even better, try with a known simple example http://www.itk.org/Wiki/ITK/HelloInsight – lib Aug 06 '15 at 10:37
  • Thx ! I tried the simple example you give me and it's work ! But it's the same things that my code. I don't know why it didn't work with my code ! – axel Aug 06 '15 at 11:03

1 Answers1

2
target_link_libraries(HelloWorld ${ITK_LIBRAIRIES})

should be

target_link_libraries(HelloWorld ${ITK_LIBRARIES})
siavashk
  • 436
  • 7
  • 24