[vtkusers] Problems with VS 2005 and VTK (vtkrendering.lib)

Obada Mahdi omahdi at gmx.de
Wed Nov 1 21:18:14 EST 2006


Hi Markus!

Please do not give up on VTK yet!  We are willing to help, but you
need to give us a chance ;-)

On 11/1/06, mam06bhv at studserv.uni-leipzig.de
<mam06bhv at studserv.uni-leipzig.de> wrote:
> Why should I use CMAKE to complie when I have Visual Studio where I create my
> projects? If I can use vtk only with Cmake I know why I've never heard before
> of it.

Here is a little motivation, from a user's side of view:
Like Amy has pointed out, It is not a compiler, it is a generator that
creates e.g. a VisualStudio project file for you, with all necessary
build parameters.  Of course you can create your VisualStudio project
manually, it _is_ possible; however, there might be several settings
for the compiler or linker which you might not be aware of, so unless
you already have some experience with setting up for the compiler and
linker of your build system (Visual Studio), you might run into
trouble.

One cannot blame VTK for the complexity of today's compilers, linkers
and build systems like Visual Studio, and I will not blame anyone who
does not have enough experience setting up compiler and linker flags
in detail (well, I certainly do not have the answer to all
build-related questions...)  CMake helps you in this regard by taking
care of choosing suitable build settigs.

----

As for the problems with your sample program: Before you are
installing VTK over and over again, I would suggest that we try to
narrow down with your existing VTK installation first.  It is just too
hard to follow if your configuration is changing constantly.

If you have not already done so, _please_ consider taking some time
and try some of the suggestions from earlier posts.  If you do, please
also keep this list informed about what things you have tried, what
steps worked and which did not, and what error messages occur, if any.
 This will provide some more valuable information to work with.  The
following is a list of some things that I would try, in order (it is
not meant to be exhaustive, but might be an inspiration for narrowing
down the problem systematically):


(1) Run other, non-VTK OpenGL applications and see if there is a
problem.  If there are problems, chances are that your graphics driver
is corrupt.  I have no idea how to fix that, but you could start by
installing new drivers for your graphics card.  This would also
indicate that the problem was not related to VTK after all.

Here is an example (probably not the best, just the first I found
browsing www.mesa3d.org):
http://www.geocities.com/shobhand/homepage.html
Just download the linked "animator.zip", extract the contents into a
temporary directory and run "test1.bat" in the "Release" subdirectory.
 There should be a window with rotating gears and stuff. (I chose this
example because it makes calls to wglCreateContext and wglMakeCurrent,
which VTK reported to fail in your case.)


(2) Download the latest binary release of VTK from
http://www.vtk.org/get-software.php#latest
and install it.

It does not contain pre-built libraries, but a Tcl interpreter with
wrapped VTK libraries built-in, which allows you to run Tcl examples
for testing purposes, without the overhead of building VTK from
source.  If OpenGL applications as tested in (1) seem to work fine,
this is a good start to check whether creating OpenGL contexts via VTK
works on your system.  By using pre-built binaries, this eliminates
any variables introduced by a custom VTK build.

Once installed, open a command shell and execute
$ vtk.exe "VTK_SOURCE_PATH/Examples/Tutorial/Step1/Tcl/Cone.tcl"
(replace "VTK_SOURCE_PATH" with the location of the VTK sources on your system)

You probably have to adjust some environment variables by adding the
directory "INSTALL_PREFIX\lib\vtk-5.0" (the directory containing
"vtk.exe") to PATH and set TCL_LIBRARY to
"INSTALL_PREFIX\lib\vtk-5.0\tcl8.4" (the directory containing
"init.tcl").

When running this example, a small window should pop up, showing a
spinning cone.


(3) Build VTK from source just as you have already done.  I am using
VTK CVS HEAD, if you use sources from the most recent release, you
will have to replace "vtk-5.1" by "vtk-5.0" in some directory names
mentioned below.

(3.0) If there are still some vtk*.dll files in your ".../system32"
directory, remove them, just to make sure.  (In the build description
you have posted earlier, it is stated that one should copy vtk*.dll
into that directory; as far as I know, copying custom-built DLLs into
the system32 diectory is discouraged, and normal users cannot do that
anyway.)

(3.1) Run CMakeSetup.exe, choosing the source directory of VTK, a
fresh build directory (called "VTK_BINARY_DIR" hereafter), and after
hitting "Configure" for the first time, choose "Visual Studio 8 2005"
as generator (it is my understanding that VS8 is what you are using).

(3.2) Do configuration via CMakeSetup.exe , and make sure that the
following options are set
BUILD_EXAMPLES: "ON"
BUILD_SHARED_LIBS: "ON"
VTK_USE_RENDERING: "ON"

You should only need to change the first two; we do not set
BUILD_TYPE, which should then default to "Debug" (I guess).  Hit
"Configure" one more time until the "OK" button becomes available;
click "OK" then to generate the "VTK.sln" solution file in the build
directory.

(3.3) Load "VTK.sln" into VS8 and build "ALL_BUILD" for building VTK,
but do _not_ install it yet.

(3.4) Open a shell via "Tools" --> "Visual Studio 2005 Command Prompt"
and change into "VTK_BINARY_DIR/bin/debug". Run ".\Cone.exe" there and
see if it works.  The result should be the same as in (2).  If it does
not work (same error as you reported before) but the Cone.tcl in (2)
did, there is indeed a problem with building VTK, and we need to dig
deeper in this direction.


(4) If running VTK examples directly from the build tree like in (3.4)
works, install VTK by building the "INSTALL" target from "VTK.sln" (I
did not change the default install prefix, so CMAKE_INSTALL_PREFIX
points to "C:\Programme\VTK" on my test system).  Do not copy any DLLs
to "WINDOWS\system32", instead add "CMAKE_INSTALL_PREFIX\VTK\bin" to
your PATH environment variable via "Control Panel"/"System"/...
Visual Studio needs to be restarted in order for these changes to take
effect from within Visual Studio.

Then create a VS8 solution file using CMake as I have described
earlier, having VTK_DIR point to "CMAKE_INSTALL_PREFIX\lib\vtk-5.1"
(if you chose a different CMAKE_INSTALL_PREFIX when configuring VTK in
CMakeSetup, adjust paths accordingly).

Note: If CMakeSetup complains that "UseVTK.cmake" could not be found:
- move "UseVTK.cmake" and "VTKLibraryDepends.cmake" from
"CMAKE_INSTALL_PREFIX\include\vtk-5.1" to
"CMAKE_INSTALL_PREFIX\lib\vtk-5.1"
- move "vtkMakeInstantiator.cmake" from
"CMAKE_INSTALL_PREFIX\include\vtk-5.1" to
"CMAKE_INSTALL_PREFIX\lib\vtk-5.1\CMake".
(These are small glitches that were introduced into VTK CVS after
changes to the installation procedure, I have not checked if there is
a bug report yet.)

Please try this step even if you do not want to use CMake afterwards.
If building your project with a .sln file created by CMake does work
and you customly created solution does not, comparing the two can
provide some hints regarding what has to be changed.


I have tried every one of these steps while writing this, using Visual
Studio 8 on a Pentium4 Mobile running WinXP SP2 with a custom CMake
and VTK from CVS (CMake 2.4 should work just fine, too), and I hope
that there is no "other half" missing in the description ;-)  Feel
free to ask if you have any question.


Regards

Obada



More information about the vtkusers mailing list