[Insight-users] Problems when using itk with another C++ tool kit

Dalal, Dhaval dalal at bnl.gov
Mon Jun 20 11:41:26 EDT 2005


Hi Luis
I got this problem fixed.
Dcmtk by default is compiled with /GR- option.
When Linked with ITK, it generated the following warning 
 C4541: 'dynamic_cast' used on polymorphic type 'itk::EventObject' with 
 /GR-; unpredictable behavior may result 
I recompiled my code with the /GR flag option set and it compiled clean when
i linked it again with itk (since itk is also compiled with this flag set).

Thanx

Regards
Dhaval

----------------------------------------------
Hi Dalal, 

Please post the CMakeCache.txt file that CMake 
generates in the binary directory of your project. 



   Thanks 



      Luis 



-------------------- 
Dalal, Dhaval wrote: 

> Hi 
> I am trying to integrate ITK with Dcmtk(a C++ Dicom Toolkit). 
> I created a small C++ project(windows application). 
> which includes some itk and dcmtk - header files and code. 
> When when i try to compile the project, i keep getting the following 
> warnings- 
> C4541: 'dynamic_cast' used on polymorphic type 'itk::EventObject' with 
> /GR-; unpredictable behavior may result 
> 
> Which means that exceptions are not enabled. I know that ITK makes use of 
> C++ exceptions.. 
> 
> So I checked my compiler settings .By selecting "project Settings" 
> - Under C/C++ 
> - Changing Category to: C++ Language 
> - But Here " Enable C++ Exceptions" is  already checked. I am using Visual

> Studio 6.0. 
> 
> Any pointers, Can i just ignore this warning? 
> my CMakeLists.txt file is 
> 
> ///////////////////////////// 
> PROJECT(DCMTKTEST) 
> 
> FIND_PACKAGE(DCMTK) 
> FIND_PACKAGE(ZLIB) 
> # Find ITK. 
> FIND_PACKAGE(ITK) 
> IF(ITK_FOUND) 
>   INCLUDE(${ITK_USE_FILE}) 
> ELSE(ITK_FOUND) 
>   MESSAGE(FATAL_ERROR 
>           "Cannot build without ITK.  Please set ITK_DIR.") 
> ENDIF(ITK_FOUND) 
> 
> 
> # Make sure the compiler can find include files from our library. 
> INCLUDE_DIRECTORIES( 
>  ${DCMTK_config_INCLUDE_DIR} 
>  ${DCMTK_dcmdata_INCLUDE_DIR} 
>  ${DCMTK_dcmingle_INCLUDE_DIR} 
>  ${DCMTK_ofstd_INCLUDE_DIR} 
>  ${DCMTK_DIR}/imagectn/include 
>  ${DCMTK_DIR}/dcmnet/include 
>  ) 
> 
> # set certain project wide flags 
> SET(CMAKE_C_FLAGS "" CACHE STRING "Flags for C compiler." FORCE) 
> SET(CMAKE_C_FLAGS_DEBUG "/nologo /MDd /W3 /GX /Z7 /Od /GR- /YX" CACHE
STRING 
> "Win32 Debug Options C Code" FORCE) 
> SET(CMAKE_C_FLAGS_RELEASE "/nologo /MD /W3 /GX /O2 /GR- /YX" CACHE STRING 
> "Win32 Release Options C Code" FORCE) 
> SET(CMAKE_CXX_FLAGS "" CACHE STRING "Flags used by the compiler during all

> build types." FORCE) 
> SET(CMAKE_CXX_FLAGS_DEBUG "/nologo /MDd /W3 /GX /Z7 /Od /GR- /YX" CACHE 
> STRING "Win32 Debug Options C++ Code" FORCE) 
> SET(CMAKE_CXX_FLAGS_RELEASE "/nologo /MD /W3 /GX /O2 /GR- /YX" CACHE
STRING 
> "Win32 Release Options C++ Code" FORCE) 
> SET(CMAKE_EXE_LINKER_FLAGS "/INCREMENTAL:NO" CACHE STRING "Win32 Linker 
> Flags" FORCE) 
> 
> FIND_LIBRARY(DCMTK_imagedb_LIBRARY libimagedb
${DCMTK_DIR}/imagectn/libsrc) 
> FIND_LIBRARY(DCMTK_dcmnet_LIBRARY dcmnet ${DCMTK_DIR}/dcmnet/libsrc) 
> 
> 
> # set _REENTRANT flag 
> ADD_DEFINITIONS(-D_REENTRANT) 
> #ADD_DEFINITIONS(-DHAVE_CONFIG_H) 
>  
> 
> INCLUDE(${CMAKE_ROOT}/Modules/FindFLTK.cmake) 
> IF(HAS_FLTK) 
>   INCLUDE_DIRECTORIES( 
>     ${FLTK_INCLUDE_DIR} 
>     ) 
>   LINK_LIBRARIES( 
>     ${FLTK_LIBRARIES} 
>     ) 
> ENDIF(HAS_FLTK) 
> 
> INCLUDE_DIRECTORIES( 
>   ${DCMTKTEST_SOURCE_DIR} 
>   ${DCMTKTEST_BINARY_DIR} 
>   ) 
> 
> IF(CYGWIN) 
>   LINK_LIBRARIES(ole32 uuid comctl32 wsock32 supc++ -lm -lgdi32) 
> ENDIF(CYGWIN) 
> 
> SET( DCMTK_GUI_SRCS 
>   dcmtkui.fl 
>   prefsui.fl 
>  ) 
> 
> IF(FLTK_WRAP_UI) 
>   FLTK_WRAP_UI(ti ${DCMTK_GUI_SRCS}) 
>  ENDIF(FLTK_WRAP_UI) 
> 
> 
> 
> SET(DCMTKTEST_SRCS 
>   cnf.h 
>   cnf.cxx 
>   cnfexnt.cxx 
>   cnfpriv.cxx 
>   cnfpriv.h 
>   ti.cxx 
>   ti.h 
>   tinet.cxx 
>   tinet.h 
>   tiquery.cxx 
>   tiquery.h 
>   tiui.cxx 
>   tiui.h 
>   prefs.h 
>   prefs.cpp 
>   dcmtk.h 
>   dcmtk.cpp 
>   main.cpp 
>   ) 
> 
> ADD_EXECUTABLE( ti ${DCMTKTEST_SRCS} ) 
> 
> 
>  TARGET_LINK_LIBRARIES( 
>   ti 
>   netapi32 
>   wsock32 
>  ${DCMTK_imagedb_LIBRARY} 
>  ${DCMTK_dcmnet_LIBRARY} 
>  ${DCMTK_dcmdata_LIBRARY} 
>  ${DCMTK_ofstd_LIBRARY} 
>  ${DCMTK_dcmimgle_LIBRARY} 
> # ${ZLIB_LIBRARY} 
>   ITKCommon 
>  ) 
> ///////////////////////////////////// 
> 
> Let me know. 
> Thanks 
> Dhaval 
> _______________________________________________ 
> Insight-users mailing list 
> Insight-users at itk.org 
> http://www.itk.org/mailman/listinfo/insight-users 
> 



More information about the Insight-users mailing list