Hello,
I am new to MITK. I successfully installed them and now I am trying to
compile a very simple cxx file. I am also using the ITK libraries and since
I had the ITK4 already installed for other projects I am linking to the ITK
version installed by MITK.
This is .cxx file (the ITK parts are excluded):
//---------------------------------------
#include "mitkPicFileReader.h"
static const unsigned int ImageDimension = 3;
typedef mitk::PicFileReader PicReaderType;
int main( int argc, char ** argv ) {
PicReaderType::Pointer r = PicReaderType::New();
char* name;
r->SetFileName(name);//a_inputFileName());
r->Update();
return EXIT_SUCCESS;
}
//----------------------------------------
This is my CMakeList.txt:
#---------------------------------------------------------------------------------------------
# include itk
SET(ITK_DIR /home/strumia/Programs/MITK/MITK-superbuild/ITK-build/)
FIND_PACKAGE(ITK)
IF(ITK_FOUND)
MESSAGE ('ITK_USE_FILE' ${ITK_USE_FILE} )
INCLUDE(${ITK_USE_FILE})
ELSE(ITK_FOUND)
MESSAGE(FATAL_ERROR "ITK not found. Please set ITK_DIR.")
ENDIF(ITK_FOUND)
# include mitk
SET (MITK_DIR /home/strumia/Programs/MITK/MITK-superbuild/MITK-build)
FIND_PACKAGE(MITK REQUIRED)
IF(MITK_FOUND)
INCLUDE_DIRECTORIES(${MITK_INCLUDE_DIRS})
ELSE(MITK_FOUND)
MESSAGE(FATAL_ERROR "MITK not found. Please set MITK_DIR.")
ENDIF(MITK_FOUND)
LINK_DIRECTORIES(${MITK_LINK_DIRECTORIES})
ADD_EXECUTABLE(PicReadWrite PicReadWrite.cxx)
TARGET_LINK_LIBRARIES(PicReadWrite ${ITK_LIBRARIES} ${MITK_LIBRARIES})
#---------------------------------------------------------------------------------------------
I have two problems:
1. If I do cmake . with this CMakeList.txt it will not find the mitk .cpp
files; for example it gives me this error
In file included from
/home/strumia/Desktop/prova_link_MITK/PicReadWrite.cxx:3:0:
/home/strumia/Programs/MITK/MITK-2012.09.0-src/Modules/IpPicSupport/mitkPicFileReader.h:26:32:
fatal error: mitkLegacyAdaptors.h: No such file or directory
2. To solve this I add to include manually all the directories.
The CmakeList.txt becomes:
#---------------------------------------------------------------------------------------------
# include itk
SET(ITK_DIR /home/strumia/Programs/MITK/MITK-superbuild/ITK-build/)
FIND_PACKAGE(ITK)
IF(ITK_FOUND)
MESSAGE ('ITK_USE_FILE' ${ITK_USE_FILE} )
INCLUDE(${ITK_USE_FILE})
ELSE(ITK_FOUND)
MESSAGE(FATAL_ERROR "ITK not found. Please set ITK_DIR.")
ENDIF(ITK_FOUND)
# include mitk
SET (MITK_DIR /home/strumia/Programs/MITK/MITK-superbuild/MITK-build)
FIND_PACKAGE(MITK REQUIRED)
IF(MITK_FOUND)
INCLUDE_DIRECTORIES(${MITK_INCLUDE_DIRS})
ELSE(MITK_FOUND)
MESSAGE(FATAL_ERROR "MITK not found. Please set MITK_DIR.")
ENDIF(MITK_FOUND)
INCLUDE_DIRECTORIES(/home/strumia/Programs/MITK/MITK-2012.09.0-src/Modules/IpPicSupport)
INCLUDE_DIRECTORIES(/home/strumia/Programs/MITK/MITK-2012.09.0-src/Modules/LegacyAdaptors)
INCLUDE_DIRECTORIES(/home/strumia/Programs/MITK/MITK-superbuild/MITK-build/modulesConf)
INCLUDE_DIRECTORIES(/home/strumia/Programs/MITK/MITK-superbuild/MITK-build)
INCLUDE_DIRECTORIES(/home/strumia/Programs/MITK/MITK-2012.09.0-src/Core/Code/IO)
INCLUDE_DIRECTORIES(/home/strumia/Programs/MITK/MITK-2012.09.0-src/Core/Code/Common;/home/strumia/Programs/MITK/MITK-2012.09.0-src/Core/Code/DataManagement;/home/strumia/Programs/MITK/MITK-2012.09.0-src/Core/Code/Algorithms;/home/strumia/Programs/MITK/MITK-2012.09.0-src/Core/Code/Rendering;/home/strumia/Programs/MITK/MITK-2012.09.0-src/Core/Code/Interactions;/home/strumia/Programs/MITK/MITK-2012.09.0-src/Core/Code/Controllers;/home/strumia/Programs/MITK/MITK-2012.09.0-src/Core/Code/Service)
INCLUDE_DIRECTORIES(/home/strumia/Programs/MITK/MITK-2012.09.0-src/Utilities/tinyxml;/home/strumia/Programs/MITK/MITK-2012.09.0-src/Utilities/mbilog;/home/strumia/Programs/MITK/MITK-superbuild/MITK-build/Utilities/mbilog)
INCLUDE_DIRECTORIES(/home/strumia/Programs/MITK/MITK-2012.09.0-src/Utilities/ipPic;/home/strumia/Programs/MITK/MITK-2012.09.0-src/Utilities)
INCLUDE_DIRECTORIES(/home/strumia/Programs/MITK/MITK-superbuild/ITK-src/Code/Common;/home/strumia/Programs/MITK/MITK-superbuild/ITK-build;/home/strumia/Programs/MITK/MITK-superbuild/ITK-src/Utilities/vxl/vcl)
INCLUDE_DIRECTORIES(/home/strumia/Programs/MITK/MITK-superbuild/ITK-build/Utilities/vxl/vcl;/home/strumia/Programs/MITK/MITK-superbuild/ITK-src/Utilities/vxl/core/vnl;/home/strumia/Programs/MITK/MITK-superbuild/ITK-src/Utilities/vxl/core;/home/strumia/Programs/MITK/MITK-superbuild/ITK-src/Utilities/vxl/vcl/config.win32/vc60;/home/strumia/Programs/MITK/MITK-superbuild/ITK-src/Utilities/vxl/vcl/config.win32;/home/strumia/Programs/MITK/MITK-superbuild/ITK-src/Utilities/vxl/vcl/config.win32/vc70;/home/strumia/Programs/MITK/MITK-superbuild/ITK-src/Utilities/vxl/vcl/config.stlport.win32-vc60;/home/strumia/Programs/MITK/MITK-superbuild/ITK-src/Utilities/vxl/core)
LINK_DIRECTORIES(${MITK_LINK_DIRECTORIES})
ADD_EXECUTABLE(PicReadWrite PicReadWrite.cxx)
TARGET_LINK_LIBRARIES(PicReadWrite ${ITK_LIBRARIES} ${MITK_LIBRARIES})
#---------------------------------------------------------------------------------------------
In this case is able to find the mitk .cpp files, but is giving linking
problems:
$make
Linking CXX executable PicReadWrite
CMakeFiles/PicReadWrite.dir/PicReadWrite.cxx.o: In function
`mitk::PicFileReader::New()':
PicReadWrite.cxx:(.text._ZN4mitk13PicFileReader3NewEv[mitk::PicFileReader::New()]+0x42):
undefined reference to `mitk::PicFileReader::PicFileReader()'
CMakeFiles/PicReadWrite.dir/PicReadWrite.cxx.o: In function
`itk::ObjectFactory<mitk::PicFileReader>::Create()':
PicReadWrite.cxx:(.text._ZN3itk13ObjectFactoryIN4mitk13PicFileReaderEE6CreateEv[itk::ObjectFactory<mitk::PicFileReader>::Create()]+0xe):
undefined reference to `typeinfo for mitk::PicFileReader'
PicReadWrite.cxx:(.text._ZN3itk13ObjectFactoryIN4mitk13PicFileReaderEE6CreateEv[itk::ObjectFactory<mitk::PicFileReader>::Create()]+0x47):
undefined reference to `typeinfo for mitk::PicFileReader'
collect2: ld returned 1 exit status
make[2]: *** [PicReadWrite] Error 1
make[1]: *** [CMakeFiles/PicReadWrite.dir/all] Error 2
make: *** [all] Error 2
Can you please help me?
Thanks,
--
-Madda-
--
-Madda-
------------------------------------------------------------------------------
Android is increasing in popularity, but the open development platform that
developers love is also attractive to malware creators. Download this white
paper to learn more about secure code signing practices that can help keep
Android apps secure.
http://pubads.g.doubleclick.net/gampad/clk?id=65839951&iu=/4140/ostg.clktrk
_______________________________________________
mitk-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mitk-users