[vtkusers] [Gdcm2] How to use vtk and gdcm in Visual Studio 2008
Mark Roden
mmroden at gmail.com
Sat Jun 18 23:45:50 EDT 2011
Hi Kourosh,
I use these two libraries together with visual studio. I prefer to
avoid mixing cmake with visual studio, because their paradigms are
very different-- so my approach is different from John's because I'm
avoiding cmake for my projects.
When you build gdcm, you have to have already built vtk. If you have,
then search your cmake options for 'vtk' and turn that on. The gdcm
cmake should automatically find the most recently cmade vtk version
and use that. If you need two versions (one that's 32 bits and on
that's 64), you'll need to build vtk twice, and then build gdcm twice,
each time pointing to different versions of the appropriate vtk
library.
My directories look like:
VTK (source from git)
VTK-build-32 (32 bit compiled cmake result directory)
VTK-instal-32 (32 bit install directory)
CMake has an outstanding issue that will not be fixed, and that is
that the default installation directory doesn't work on modern
versions of windows unless you're running as administrator. So, you
should change the installation directory to be something near the
build directory. In there, you'll get bin, lib, and include
directories. This structure is mimicked for gdcm.
Once you've 'installed' to those directories, just point visual
studio's includes to the include directories, the linker to the lib
directory, and copy the dlls from the bin directory into your binary
directory either by hand or through a post-build step. To me, this
approach is simpler than the CMakeFiles.txt approach.
Good luck,
Mark
On Sat, Jun 18, 2011 at 1:14 PM, John Drescher <drescherjm at gmail.com> wrote:
> 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
>
> ------------------------------------------------------------------------------
> EditLive Enterprise is the world's most technically advanced content
> authoring tool. Experience the power of Track Changes, Inline Image
> Editing and ensure content is compliant with Accessibility Checking.
> http://p.sf.net/sfu/ephox-dev2dev
> _______________________________________________
> Gdcm-developers mailing list
> Gdcm-developers at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gdcm-developers
>
More information about the vtkusers
mailing list