Friday, April 13, 2007

Build VTK from source in Visual Studio

Here is the reference document on how to build VTK from source in Visual Studio and configure Visual Studio IDE



After you installed VTK and configure Visual Studio IDE. You can use this minimal project file to test your installation.

41 comments:

Anonymous said...

Dear Sir,

I am start using with the VTK by installing it in Window OS. However, I try on the example which you provided. However, i get an error : "fatal error C1083: Cannot open include file: 'vtkActor.h': No such file or directory"

Few Question:
1. When I create a simple C++, may re-configure again in Cmake?

2. Then, do i need to re-build the ALL BUILD in C++?

Thanks!! :)

Shi Yun (valerie_lsy@msn.com)

Peter said...

No. You only need to follow my guidelines (if you are using VC++) and build VTK using CMake ONCE. Then, you can use VTK for any projects as you like.

Unless you change the configuration in CMake, otherwise you don't need to rebuild.

zames roh said...

Hi, Thank you for the tutorial :)
It is very helpful for me

And I have a question

When I started debugging,
VC7 said there is no vtkRendering.dll.

So Where can I find the dll files?

Thank you.
Have a good day

quintalzinho said...

Thanks Peter for the guide!!!

I encountered one little problem. Some of the lib-files are installed in the build directory specified during cmake ("where to build the binaries?"). There exists a subfolder /bin/debug where all lib-files are located.

Adding this path to lib path in Tools->Options of VS resolved the problem.

My question is: Did you miss this detail in your guide or did I something wrong during installation (e.g. I chose "Build solution" to build the "Build-ALL" of vtk.sln) ?

Sebastian

Anonymous said...

Thanks. It's really an excellent tutorial.

One question: Why do we have to set Runtime Library to "Multi-threaded DLL (/MD)" for the vtk_minimal project? Any other setting doesn't work.

ShiX said...

Hi Peter, I just came across you weblog and I really found it interesting. I've just started using VTK in C++. I'm a java programer myself but because I couldn't workout VTK in Java I switched to C++ so I'm both new in C++ and VTK which makes things quit tough. I'd be probably bothering you with my questions from now on. For start may I ask you why you're building install project. I always only build All_build. would there be any difference?
Thanks
Shaady

ShiX said...

Thanks so much Pater, This was great. I just built a project using your setting without using CMAKE to make my C++ project. Thanks alot

Anonymous said...

Sir, I am using VTK in linux Debian etch. I'm install VTK using apt-get install vtk-tcl vtkdata vtk-doc, so I never using CMake to build it. when I try to build some vtk files using C++ files (namefiles.cpp), I've got error message
:vtkActor.h': No such file or directory.

the question is :
1. how to repair it?
2. when I try to run vtk for tcl files, it's works.but for c++ files, i get an error. isn't my way to compile vtk is wrong??

Peter (admin) said...

Hi,

Referring to the post (07 February 2008 03:08).

I am not quite sure about Debian Linux. But I have experiences using Ubuntu, which is also Debian-based Linux distribution.

I think, you should try to apt-get install vtk-dev. I think this package may be available. For vtk-tcl, it should be a package for tcl script development. The other two is for documentation and the dataset used by VTK respectively.

Hope this comment helps. Cheers!

Peter said...

Hi,

Referring to: (for not found header files problems)

Sorry for the late reply (It is because I hadn't setup the comment tracking system previously).

"Header files not found" is usually resulted when you haven't setup your IDE (e.g. Visual Studio) "Include path" correctly. See the install guide to fix this problem.

Anonymous said...

Hello Peter,
I found your tutorial very helpful for installing VTK. I have made all the setting listed in the tutorial. I am able to build and execute the sample code provided by you in VC++ 8.0. However when I try to execute sample codes from vtk.org I get compiler errors (Eg. Error 1 fatal error C1083: Cannot open include file: 'vtkXOpenGLRenderWindow.h': No such file or directory )
and linker errors (Eg. error LNK2019: unresolved external symbol "public: void __thiscall vtkRenderer::AddActor(class vtkProp *)"
I have included the path for include and lib files in the VC project. Have I missed some other setting? Can you tell me how to overcome this problem?

Thanks in advance,

Regards,
Sumit

Peter said...

Hi Sumit,

In this sample code, I think vtkXOpenGLRenderWindow is a platform dependent class. It can only be used in X Window system (e.g. Linux).

Instead of using vtkXOpenGLRenderWindow, you may choose to use vtkRenderWindow. This class will automatically select the appropriate class in different platform.

Peter

Peter

Anonymous said...

Hello Peter,
Thanks for your previous reply. However there is one more problem. The code executes well in the Release mode but in the Debug mode I get a runtime error "A buffer overrun has occurred in vtk_trial.exe which has corrupted the program's internal state". I am using Multi-threaded DLL (/MD) as the runtime lib.
If possible can you point out what could be the problem?
Thanks in advance.

Regards,
Sumit

Peter said...

Hi Sumit,

I don't know the detail cause when you switched to the debug mode. May be you can change the runtime library configuration as "Multi-threaded Debug DLL (/MDd)".May be it can solve your problem.


Peter

Chaos wizard said...

Hi, peter
First of all, thanks for your VTK install tutorial, that was gr8!
But I have a problem after I finished install VTK, I tried to write function like
#include "vtkPoints.h"
...
void DrawDelaunay2D()
{
vtkPoints *pts = vtkPoints::New();
}
...
and then I got a link error:
Stroke.obj : error LNK2019: unresolved external symbol "public: static class vtkPoints * __cdecl vtkPoints::New(void)" (?New@vtkPoints@@SAPAV1@XZ) referenced in function "public: void __thiscall Stroke::processStroke(void)" (?processStroke@Stroke@@QAEXXZ)
1>C:\Documents and Settings\Rong\My Documents\Visual Studio 2008\Projects\LifeSketch\Debug\LifeSketch.exe : fatal error LNK1120: 1 unresolved externals
Do u have any idea about that?
Thank you very much!

Rong

Anonymous said...

Hi,
I'm aving problems with the INSTALL project.

I'm using VS2008 Express, all steps in the instructions work up to numer 8.

I select the INSTALL project after the sucessful completion of the ALL_BUILD project and select build project. VS then tells me there is noting to do and does not install my files to the location I identified in CMake.

Has anyone else had this problem?

Thanks!

Peter said...

Dear Freddo,

In step 5, when you press the configure button, you should able to choose which version of Visual Studio. I think there is one option of visual studio 2008. I remember that the default is not VS2008.

Peter

Anonymous said...

Hi Peter,

Started again from scratch, the ALL_BUILD completes without errors, but I still get the following message:

------ Skipped Build: Project: Continuous, Configuration: Release Win32 ------
Project not selected to build for this solution configuration
------ Skipped Build: Project: NightlyMemoryCheck, Configuration: Release Win32 ------
Project not selected to build for this solution configuration
------ Skipped Build: Project: INSTALL, Configuration: Release Win32 ------
Project not selected to build for this solution configuration
------ Skipped Build: Project: RUN_TESTS, Configuration: Release Win32 ------
Project not selected to build for this solution configuration
------ Skipped Build: Project: Experimental, Configuration: Release Win32 ------
Project not selected to build for this solution configuration
------ Skipped Build: Project: Nightly, Configuration: Release Win32 ------
Project not selected to build for this solution configuration
========== Build: 0 succeeded, 0 failed, 53 up-to-date, 6 skipped ==========

Anonymous said...

I've just built VTK on Viusal Studio 2008 and it worked fine. I'll go back and find out what happened in 2008 Express.

Anonymous said...

I did compile successfully myself the source code for Visual studio 2005 using Cmake. I also set up the environment variables like shown in the guidelines. But when i started putting the vtk code into my project, it generated the link errors:
Linking...
LINK : warning LNK4098: defaultlib 'LIBCMTD' conflicts with use of other libs; use /NODEFAULTLIB:library
DialogBar3D.obj : error LNK2019: unresolved external symbol "public: void __thiscall vtkCamera::Zoom(double)" (?Zoom@vtkCamera@@QAEXN@Z) referenced in function "public: void __thiscall CDialogBar3D::HoleTriangulation(void)" (?HoleTriangulation@CDialogBar3D@@QAEXXZ)

I spent pretty much time to figure out, even tried to included all the .lib names in the additional libraries, but it doesnt work adn even generated much more those crazy errors.
Peter, do you have any idea about those errors?

Anonymous said...

Thanks so much for the tutorial!

sam said...

hi Peter,
gr8 work , i just want to add the after following the build and installation steps i was getting vtkfilter.dll ect not found
the steps documented donot mention that we have to copy vtk*.dll files to system32 folder . i wonder how it worked for every one else. Many thaks for your work
sam

Unknown said...

Hi, I was able to follow all your steps and right now running the vtk_minimal project. I am getting fatal error when i try it, the following statement is where the error occurs: " vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();"

Can you please tell me what could be the reason. Thanks

Unknown said...

solved it, was building in debug :)

R said...

Hi,

I keep getting a fatal error in vtk_minimal.exe. on the line
v->value = value in the file vtkInformationStringKey.cxx

vtkInformationStringValue* v = new vtkInformationStringValue;
this->ConstructClass("vtkInformationStringValue");
v->Value = value;

Could you please let me know how to fix this ?

Ben Lee said...

I get the same error as R's; is it because of version difference? I'm using VTK 5.4.

Ben Lee said...

I get the same error as R's; is it because of version difference? I'm using VTK 5.4.

ALi Mahmoud Habib said...

I use .NET 2008 and build the "Build all" , but when try to build install project it give error

cross compiling fetal error

Any help please

Unknown said...

thanks for the tutorial, but which Cmake option shall we use to get the *.lib? I am getting only *.dll files without the lib stubs!

Anonymous said...

I have installed VTK, But I am getting an error of VTK.Rendering.dll not found.
I search in bin, and there is this dll file present.
Then I add this path to my VSC++. But still getting same problem...

Usman said...

I have installed VTK, But I am getting an error of VTK.Rendering.dll not found.
I search in bin, and there is this dll file present.
Then I add this path to my VSC++. But still getting same problem...

Anonymous said...

Dear Sir,
Thank you for your code.
Since I am a novice user, I am wondering "project_config.h" file.
Please let me know what is the advantage of specifying #pragma than by specifying "Addtional Dependencies" in Linker Settings? Which is the best way?
Please explain to me.

Thanks,
Nelson

Srinivasan said...

Hi,
Thanks for the tutorial. I followed exactly the same procedure as given in your tutorial, but I have a lot of linker errors. The first error happens because the file vtkverdict.lib is not found. All other errors follow because of his. Any help in resolving this error will be hightly appreciated

Srinivasan.B

Srinivasan said...

Hi,
I forgot to mention in my previous post that I am using Visual Studio 2010 and QT version 4.7.3

Srinivasan.B

Antonio said...

Hi Peter, thank you very much for your help guide...I've followed your guide in every step and everything has worked in the right way...now the problem is that often, when I try to compile a project i find the linker error LNK2019....can you help me? Please, i'm going crazy....thank you very much!!

Soumya said...

Thank you Very much... I compiled it in debug mode and it worked too.. thanks :)

Anonymous said...

Hello there! This blog post couldn't be written much better! Reading through this post reminds me of my previous roommate! He constantly kept talking about this. I most certainly will forward this article to him. Pretty sure he's going to have a very good read.

Many thanks for sharing!

Have a look at my site: diet plans for women
my web page > diet plans for women

Anonymous said...

www.fortinet.com

Create your own site, avoid blogs. What all you need is router, UTM firewall device, switch, SERVER. Run it 10 hours a day from home.
Register to bigrocks.com

Network Security, UTM, Next Generation Firewall, Endpoint Security Appliances. FortiGuard Center; Fortinet Blog; Video Library; Contact Us; Products. Network Security.

www.cisco.com

mail me : wisemen2013@outlook.com

Anonymous said...

e cigarette, smokeless cigarettes, electronic cigarettes, electronic cigarette, e cigarette, e cigarette

Unknown said...

Hi ,I use visual studio 2013 I need to set up environment variables inside the Visual Studio 2013 IDE but I don't found the same step in the tutorial?? please help me

Anonymous said...

hi, i have installed VTK but i am getting an error such as cannot open include file: vtkRenderWindow.h: no such file or directory. could you please let me know how to fix this?