[ITK-users] Brand new project with itk sentence with QtCreator, Qt5 and Cmake crashes

Marcos fotosentido at gmail.com
Fri Aug 14 11:57:45 EDT 2015


Hi,

I'm just trying to make a Cmake project compile and debug. Nothing else.
I've spent hours trying different things.

It's just a first try to start coding, but it doesn't work. I explain
everything in detail, that's why this post is so long, but I just want to
remark I'm just trying to setup ITK. Nothing else.


I've tried with the .pro configuration. It compiles, until I use some itk
object, then it returns:
unresolved external symbol...: itksys-4.8.lib (it's included in the .pro
file)


So I'm trying with Cmake. Everbody recommends it, but I didn't see a
straight tutorial to set up a simple project with QtCreator and Qt5. So I'm
trying it myself.

I'm using Windows 7, compiling and installing with Visual Studio 2013.
I've compiled and installed successfully VTK first and then ITK (checking
ITVVTKGlue).

I have built them in:
C:\VTK-6.2.0-build
C:\ITK-4.8.0-build

I have them installed in:

C:\VTK-6.2.0-installed
C:\ITK-4.8.0-installed
(Each one has the subdirectories \bin, \include, \lib and \share)

So, I created a QT5 Widgets project from QtCreator, then I added a
CMakeLists.txt containing:

CMAKE_MINIMUM_REQUIRED(VERSION 2.8.11)
>
>
> PROJECT (UtilityDICOM)
>
>
> SET(CMAKE_INCLUDE_CURRENT_DIR ON)
>
> SET(CMAKE_AUTOMOC ON)
>
>
> FIND_PACKAGE(Qt5Widgets REQUIRED)
>
>
> # VTK
>
> #SET(VTK_DIR "C:\\VTK-6.2.0-build\\")
>
>
> # ITK
>
> #SET(ITK_DIR "C:\\ITK-4.8.0-build\\")
>
> FIND_PACKAGE(ITK REQUIRED)
>
> INCLUDE(${ITK_USE_FILE})
>
>
> IF (ItkVtkGlue_LOADED)
>
>     FIND_PACKAGE(VTK REQUIRED)
>
>     INCLUDE(${VTK_USE_FILE})
>
> ENDIF()
>
>
>
> ADD_EXECUTABLE(UtilityDICOM WIN32 main.cpp mainwindow.cpp)
>
>
> TARGET_LINK_LIBRARIES(UtilityDICOM Qt5::Widgets ${Glue} ${VTK_LIBRARIES} ${ITK_LIBRARIES})
>
>


It returns the error:

CMake Error at CMakeLists.txt:15 (FIND_PACKAGE):

By not providing "FindITK.cmake" in CMAKE_MODULE_PATH this project has

asked CMake to find a package configuration file provided by "ITK", but

CMake did not find one.


Could not find a package configuration file provided by "ITK" with any of

the following names:


ITKConfig.cmake

itk-config.cmake


Add the installation prefix of "ITK" to CMAKE_PREFIX_PATH or set "ITK_DIR"

to a directory containing one of the above files. If "ITK" provides a

separate development package or SDK, be sure it has been installed.




Ok, so I uncommented the lines you see. Why do I added the build folders
and not the installed folders? Because I got the same error with the
installed dirs.

After doing that, it compiled, but I got another error when launching:

C:\Users\M\Documents\REPOSITORIO\trunk\UtilidadDICOM\mainwindow.cpp:2:
error: C1083: Cannot open include file: 'ui_mainwindow.h': No such file or
directory

Searching for an answer, I found something here:
https://chan20kaur.wordpress.com/tag/qt-and-cmake/

I changed my CMakeLists.txt to:

CMAKE_MINIMUM_REQUIRED(VERSION 2.8.11)
>
>
> PROJECT (UtilityDICOM)
>
>
> FIND_PACKAGE(Qt5Widgets REQUIRED)
>
>
> SET(CMAKE_INCLUDE_CURRENT_DIR ON)
>
> SET(CMAKE_AUTOMOC ON)
>
>
> QT5_WRAP_UI(Cmake_form_hdr mainwindow.ui)
>
> add_library(mainwindow mainwindow.cpp ${Cmake_form_hdr})
>
> qt5_use_modules(mainwindow Widgets)
>
>
> # VTK
>
> SET(VTK_DIR "C:\\VTK-6.2.0-build\\")
>
>
> # ITK
>
> SET(ITK_DIR "C:\\ITK-4.8.0-build\\")
>
> FIND_PACKAGE(ITK REQUIRED)
>
> INCLUDE(${ITK_USE_FILE})
>
>
> IF (ItkVtkGlue_LOADED)
>
>     FIND_PACKAGE(VTK REQUIRED)
>
>     INCLUDE(${VTK_USE_FILE})
>
> ENDIF()
>
>
>
> ADD_EXECUTABLE(UtilityDICOM WIN32 main.cpp)
>
> TARGET_LINK_LIBRARIES(UtilityDICOM mainwindow ${Glue} ${VTK_LIBRARIES} ${ITK_LIBRARIES})
>
> QT5_USE_MODULES(UtilityDICOM Core Gui Widgets)
>
>

With this, I compile. And I can launch the executable.


So I added a ITK line. In main.cpp, I added in main method:

itk::Object::GlobalWarningDisplayOff();
>

including

#include <itkObject.h>
>

Just that. By the way, the editor autocompletes this include. And I got:

Starting
> C:\Users\M\Documents\REPOSITORIO\trunk\UtilidadDICOM-build\UtilityDICOM.exe...

The program has unexpectedly finished.


Ok, what now? I just added ONE LINE.

I don't have any clues.

I tought maybe it could be that method.

So I changed my modification to:



typedef itk::Image< double, 2 > ImageType;

typedef itk::ImageFileReader<ImageType> ReaderType;


ReaderType::Pointer reader = ReaderType::New();

with
#include <itkImageFileReader.h>


Same result.
I don't know what to do, really. I read
blogs, wiki entries,... I spent days trying to use this, what am I doing
 wrong? Am I missing something?

I will keep trying, but it's so frustating not being able to even start coding.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/insight-users/attachments/20150814/2bb720ee/attachment.html>


More information about the Insight-users mailing list