[Insight-users] can't compile HelloWorld with Visual Studio 9 2008

John Drescher drescherjm at gmail.com
Tue Feb 22 09:20:26 EST 2011


> I think the point is that the choice in cmake must agree with the choice in
> MSVS.  That is, if you chose Release build in cmake, you must also choose
> the Release build in MSVS.  If you chose both Release and Debug in cmake,
> you can build either with MSVS.  This is my understanding.
>

In Visual Studio to use ITK, VTK, GDCM in both Debug and Release mode
you must not build the INSTALL target. The reason for not installing
the INSTALL target is that the library/dlls names for these are the
same in Debug and Release mode and for Visual Studio that is a big
problem. A Debug program can not generally link against a Release
library and visa versa otherwise the application may experience
crashes since the debug and release memory allocation/deallocation
routines are incompatible. To avoid this problem just build the
solution for both Debug and Release then for your application when you
configure with cmake-gui set the variable to point to the location you
built the library. For ITK that variable os ITK_DIR the other two I
mentioned are VTK_DIR and GDCM_DIR. To build these libraries on Visual
Studio, after configuring and generating the Visual Studio solution I
generally open the appropriate Visual Studio Command prompt and change
directory to the build folder for the library and type

vcbuild

That will build the Debug and Release configurations for all targets
except INSTALL, PACKAGE and a few others that you do not want to build
most of the time anyways.


BTW, I wanted to mention my build structure to support for out of
source building and multiple compilers with 32 and 64 bit projects.
I use the following for my source dir for ITK

X:\CMakeBased\Libraries\ITK-3.20

My build folder for ITK in 32 bit Visual Studio 2008 (VC90) is:

X:\32bit\VC.90\Libraries\ITK-3.20

With this directory structure all source code that is built using
CMake to generate projects goes in X:\CMakeBased. All binaries either
go in x:\32bit\VC.90, x:\64bit\VC.90, x:\32bit\VC.80 or x:\64bit\VC.80
depending on what compiler and 32 or 64 bit that I am using. I Also
try to mirror the paths from the source to the build folder. So my Qt
based projects are in

X:\CMakeBased\Qt

and the build folder for these are in

X:\32bit\VC.90

Two examples of this (the 2 major projects I have written since 2008
using CMake are LungAnalysis and StudyManager). Both use Qt. So my
folders for these are

X:\CMakeBased\Qt\StudyManager
X:\CMakeBased\Qt\LungAnalysis

and then the build folders are now mainly (I do build other
configurations but these are the ones most used):

X:\64bit\VC.90\Qt\LungAnalysis
X:\32bit\VC.90\Qt\StudyManager

For all of my own source code in CMakeBased I have that in my own
subversion server.

John


More information about the Insight-users mailing list