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

Obada Mahdi omahdi at gmx.de
Tue Oct 31 10:53:10 EST 2006


Hi Markus,

it is hard to understand your problem without more specific
information about the build process and the error message.  Still,
here are some guesses:

On 10/31/06, Markus voigt <markus-voigt at gmx.net> wrote:
> David Cole schrieb:
> > (1) Please post the error output of the compiler/linker...
> that's not possible because in the moment my PC compiles the ALLBUILD
> from Cmake again

It sounds like this step takes a considerable amount of time.  Is
there any chance that by "ALLBUILD from Cmake" you are actually
referring to building VTK itself, after having it configured with
CMake for compilation using VisualStudio?

Maybe there is some confusion: CMake is not specific to VTK, it is
more an all-purpose configuration tool, much like the widely used
autoconf/automake tag team on GNU/Linux systems.  It is capable of
figuring out the build environment and generate project files for a
variety of build systems, including Makefiles for GNU make or
"Solutions" for VisualStudio 8.

My best guess is that you have built and installed VTK successfully,
and then created a C++ VisualStudio project, set up the header search
path to point to the "include/vtk-<version>" subdirectory of your VTK
installation and added "vtkRendering.lib" to the list of additional
libraries.  Is this about right?

If that is the case, the errors you are encountering are most probably
"LNK2001" messages from the linker complaining about unresolved
symbols referenced from parts of "vtkRendering.lib" (or the
corresponding DLL).  It happens because this library depends on other
VTK libraries, like vtkCommon.lib and others.  One solution to this
problem is to figure out these dependencies and add additional
libraries by hand (described elsewhere in the mailing list archive).

The preferred way to create projects that link against VTK is to use
CMake, which is what David was referring to:

> > (3) Are you using CMake to generate a project that compiles the cpp
> > file you sent in your first post?

Just create a project description file called "CMakeLists.txt", which
tells CMake how to configure and build your project, independently of
the build system that will be used for compilation--many simple
examples can be found the the "Examples" subdirectory of the VTK
source tree.  Then you can use CMake to create e.g. a VisualStudio
Solution for you project, which you can load and build within
VisualStudio just like you did with VTK.

It is worth noting that library dependencies are not the only build
parameters that have to be figured out manually if CMake is not used,
among others are:

- static vs. shared runtime libraries: if VTK was built with static
libs, you have to explicitly choose static runtime libraries for your
project, otherwise you will most probably end up with clashing symbols
from libc.lib and msvcr80.dll (or similar)

- debug vs. release libraries: if VTK was linked against debug runtime
libraries (libcd.lib or msvcr80d.dll, for example), so must your own
project.

Well, this is neither a comprehensive list, nor am I sure that it is
correct--I am just mentioning this to scare you off ;-)  Seriously,
there are rarely good excuses for not using CMake, and if you are
unsure how to set up compiler/linker settings and additional
libraries, it can be rather annoying and time-consuming to do all this
by hand.


Please let us know if you have further questions or more information
about your problem.


Regards

Obada



More information about the vtkusers mailing list