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

mam06bhv mam06bhv at studserv.uni-leipzig.de
Wed Nov 1 08:25:35 EST 2006


Obada Mahdi schrieb:
> 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
> _______________________________________________
> This is the private VTK discussion list. Please keep messages 
> on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
Hi Obada

sorry for my bad english. I can imagine that you don't know what my 
problem is.
For now I have done this what you can see on this webpage
http://www.cs.auckland.ac.nz/~jli023/vtk/BuildandinstallVTKbinaries.htm

After that, I can compile the program and it is starting with no errors 
for the time being.
When the VTK window (not the command line window) pop up these error 
messages are written in VTK window.

ERROR: In ..\..\VTK\Rendering\vtkWin32OpenGLRenderWindow.cxx, line 824
vtkWin32OpenGLRenderWindow (01970FD0): wglCreateContext failed in 
CreateAWindow(), error: 1114

ERROR: In ..\..\VTK\Rendering\vtkWin32OpenGLRenderWindow.cxx, line 824
vtkWin32OpenGLRenderWindow (01970FD0): wglCreateContext failed in 
CreateAWindow(), error: 0

ERROR: In ..\..\VTK\Rendering\vtkWin32OpenGLRenderWindow.cxx, line 824
vtkWin32OpenGLRenderWindow (01970FD0): wglCreateContext failed in 
CreateAWindow(), error: 6

I'm using Visual Studio .NET 2005. I created a new project (Visual C++ 
project ->Win32 Console Application) and put in these code lines:

#include "stdafx.h"
#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkConeSource.h"
#include "vtkPolyDataMapper.h"
#include "vtkActor.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkProperty.h"


int _tmain(int argc, _TCHAR* argv[])
{
   char a;

   vtkRenderer * ren = vtkRenderer::New();
   vtkRenderWindow *renWindow = vtkRenderWindow::New();
     renWindow->AddRenderer(ren);
   vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
     iren->SetRenderWindow(renWindow);

   vtkConeSource *cone = vtkConeSource::New();
     cone-> SetResolution(8);
   vtkPolyDataMapper *coneMapper = vtkPolyDataMapper::New();
     coneMapper->SetInput(cone->GetOutput());
   vtkActor *cone1 = vtkActor::New();
     cone1->SetMapper(coneMapper);
     cone1->GetProperty()->SetColor(0.200,0.6300,0.7900);
     cone1->GetProperty()->SetDiffuse(0.7);
     cone1->GetProperty()->SetSpecular(0.4);
     cone1->GetProperty()->SetSpecularPower(20);

   vtkProperty *prop = vtkProperty::New();
     prop->SetColor(1.000,0.3882,0.2784);
     prop->SetDiffuse(0.7);
     prop->SetSpecular(0.4);
     prop->SetSpecularPower(20);

   vtkActor *cone2 = vtkActor::New();
     cone2->SetMapper(coneMapper);
     cone1->SetProperty(prop);
     cone1->SetPosition(0,2,0);

     ren->AddActor(cone1);
   ren->AddActor(cone2);

   renWindow->Render();

   iren->Start();
 

   return 0;
}

Thanks for help
Markus



More information about the vtkusers mailing list