[vtkusers] How to use vtk and gdcm in Visual Studio 2008

John Drescher drescherjm at gmail.com
Sat Jun 18 16:14:44 EDT 2011


On Sat, Jun 18, 2011 at 3:42 PM, Jafari, Kourosh <kjafari at rad.hfh.edu> wrote:
> Dear vtk users,
>
> I am trying to use vtk and gdcm together in Visual Studio 2008. I already had vtk 5.6.0. I downloaded and built gdcm 2.0.17 using CMake and Visual Studio 2008. It built gdcm with 20 errors. For example:
>
>
> 13>gdcmJPEG2000Codec.obj : error LNK2019: unresolved external symbol __imp__gdcmopenjpeg_opj_stream_set_seek_function at 8 referenced in function "void * * __stdcall gdcm::opj_stream_create_memory_stream(struct gdcm::myfile *,unsigned int,bool)" (?opj_stream_create_memory_stream at gdcm@@
>
>
> Now I have generated a simple project using the following CMakeLists.txt:
>
> cmake_minimum_required(VERSION 2.8)
> PROJECT(TestGDCM)
> FIND_PACKAGE(VTK REQUIRED)
> INCLUDE(${VTK_USE_FILE})
> FIND_PACKAGE(GDCM)
> IF(GDCM_FOUND)
>    INCLUDE(${GDCM_USE_FILE})
> ENDIF(GDCM_FOUND)
> INCLUDE_DIRECTORIES (
>  ${VTK_INCLUDE_DIR}
>  ${CMAKE_CURRENT_BINARY_DIR}
>  ${CMAKE_CURRENT_SOURCE_DIR}
>  )
> LINK_LIBRARIES (
>  vtkCommon
>  vtkRendering
>  vtkIO
>  vtkFiltering
>  vtkGraphics
>  vtkWidgets
>  vtkImaging
>  vtkHybrid
>  vtkCharts
>  vtkVolumeRendering
>  )
> ADD_EXECUTABLE(TestGDCM TestGDCM.cxx)
> TARGET_LINK_LIBRARIES(TestGDCM)
>
> I get the following compilation errors:
>

Move all lines from LINK_LIBRARIES to TARGET_LINK_LIBRARIES. Also add
the following two lines to TARGET_LINK_LIBRARIES

So your CMakeLists.txt should look like this:

cmake_minimum_required(VERSION 2.8)
PROJECT(TestGDCM)
FIND_PACKAGE(VTK REQUIRED)
INCLUDE(${VTK_USE_FILE})
FIND_PACKAGE(GDCM)
IF(GDCM_FOUND)
   INCLUDE(${GDCM_USE_FILE})
ENDIF(GDCM_FOUND)
INCLUDE_DIRECTORIES (
 ${VTK_INCLUDE_DIR}
 ${CMAKE_CURRENT_BINARY_DIR}
 ${CMAKE_CURRENT_SOURCE_DIR}
 )

ADD_EXECUTABLE(TestGDCM TestGDCM.cxx)
TARGET_LINK_LIBRARIES(TestGDCM
 gdcmMSFF
 vtkgdcm
 vtkCommon
 vtkRendering
 vtkIO
 vtkFiltering
 vtkGraphics
 vtkWidgets
 vtkImaging
 vtkHybrid
 vtkCharts
 vtkVolumeRendering
 )

John



More information about the vtkusers mailing list