[vtkusers] How to introduce the VTK in the Microsoft Visual Studio 2008 MFC

John Drescher drescherjm at gmail.com
Wed Mar 6 09:39:07 EST 2013


>      I have already built VTK  .  But  how to use cmake to build MFC
> projects still do not understand.
>     1.Suppose I have established the MFC single document project. This is
> name" VTK_ext". Delete  VTK_ext.sln  and VTK_ext.ncb

I would just move the headers, resources and cpp files to a different
location and create a CMakeLists.txt file for your project. You do not
want any of the Visual Studio generated files at all. Also I recommend
that you build out of source so in the cmake-gui make sure that you
specify a build folder that is not in the source tree of your project.

>     2.To find a file  ,its name is CMakeLists.txt  in VTK  DIR
> (D:\vtk\vtk\Examples\GUI\Win32\vtkMFC\vtkSDI),
> and modify this file. ( VTK_ext  instead of  vtkSDI ) .

You should at least create a CMakeLists.txt in the root folder of your
project. You can copy some bits from an example however I doubt that
this will work without tinkering. Make sure you spend some time to
learn CMake.

>    3.start Cmake.  soure code : "D:/Documents/Visual Studio
> 2008/Projects/VTK_ext"   (CMakeLists.txt  copy of this folder)
>                           build  the  binaries: "D:/Documents/Visual Studio
> 2008/Projects/VTK_ext/VTK_ext"
>      configure---> Generate--->

I would put the build tree in a totally separate tree for example my
code for a program called LungAnalysis is in

X:\CMakeBased\Qt\LungAnalysis

and then my 64 bit build for VS 2010 is in

X:\64bit\VC.100\Qt\LungAnalysis

and the 32 bit build for VS 2010 is in

x:\32bit\VC.100\Qt\LungAnalysis

>   4. Use  vc2008 to open  VTK_ext.sln    ,  press  F5 ,Pop-up window
> (title is Executable For Debug Session)
>    The above method which is not correct, please advice!

Make sure you select the correct startup project after you generate
(right click on the solution view to set the startup project). The
default project will be ALL_BUILD which does not create an executable
so it can not run when you press F5.

John



More information about the vtkusers mailing list