Part 2

C++ Part 2: Installing, configuring, and testing C++ and VTK
using Visual Studio .NET

This tutorial shows how to install vtk for use in Visual C++ .Net.

Download the following files:



Install both of the above files. Take note of where these files are installed as you will need to know later. For this example we are installing it to c:\vtk40

Launch Visual Studio .Net choose New Project. In the new dialog box that comes up select Visual C++ Projects, then Win32 Project. Under location Choose the folder where you wish this project to be created and type a name for this project. Then click OK.

Now in the following dialog box select Application Settings. Under Application type choose Console Applications, and then click Empty project. Then select Finish.

Now we need to add our sample source file. In the directory where you installed vtk40CPP (example: c:\vtk40) there should be a folder called CxxExample in that folder there is a file called Cone.cxx. Copy that file to the location where you chose for your Visual C++ project.

In the solution explorer right-click on the Source Files folder. Choose the Add->Add existing item option. Select the Cone.cxx file.

Now select the Tools->Options menu. You should get the following window.

Select the Projects then VC++ Directories tab, and make sure the Show directories drop-down is set to include files. Click the new button (the icon to the left of the red X).

Click on the browse button. In the dialog box that shows up browse to the location where the C++ header files are located. (example: C:\VTK40\INCLUDE\VTK) then click OK. Now change the Show directories drop-down to Library Files. Add a new line as we did above and browse to the location where the C++ library files are installed. (example: C:\vtk40\lib\vtk). Now click OK to close the options dialog.

Now we need to tell VC++ which library files we want to link in with our executable. To do so right-click on your project name in the solution explorer and select properties. You should get the following dialog box:

In the dialog select Configuration Properties->Linker->Input

Select Additional Dependencies and click the browse button. You should get an additional dependencies dialog box that looks like thise:

In the white box at the top enter in the following five lines:

vtkCommon .lib

Click OK to close the additional dependencies dialog box, then click OK again to close the project properties dialog box.

We are now ready to compile.

Select the Debug->Start menu.

After compilation the program will run and you should see a spinning cone:

For any future C++ VTK programs you will need to make sure that the include and library paths are set as well as inform VC++ to link in the vtk library files.

C++ Tutorial
Python Tutorial
TCL/TK Tutorial

About Us

C++ Tutorial
Part 1: VS 6
Part 2: VS .NET
Part 3: SUU Logs