[vtkusers] Linking to VTK static libraries on Windows

Gib Bogle g.bogle at auckland.ac.nz
Fri Oct 15 00:32:04 EDT 2010


I've shifted to a simpler example.  I have a very basic Qt/VTK test program 
(QVTK_test) which works when linked to VTK shared libraries.  It uses QVTKWidget 
and vtkRenderWindowInteractor to render a cylinder.  As such it is very similar 
to the VTK Cylinder example - it also uses ctkCylinderSource.
VTK-src\build\examples\all\rendering
The Cylinder example builds correctly with static VTK libraries, with no 
warnings.  My QVTL_test build gives this output (some warnings and one error):

1>mainwindow.obj : warning LNK4217: locally defined symbol 
?Zoom at vtkCamera@@QAEXN at Z (public: void __thiscall vtkCamera::Zoom(double)) 
imported in function "public: __thiscall MainWindow::MainWindow(void)" 
(??0MainWindow@@QAE at XZ)
1>mainwindow.obj : warning LNK4217: locally defined symbol 
?GetActiveCamera at vtkRenderer@@QAEPAVvtkCamera@@XZ (public: class vtkCamera * 
__thiscall vtkRenderer::GetActiveCamera(void)) imported in function "public: 
__thiscall MainWindow::MainWindow(void)" (??0MainWindow@@QAE at XZ)
1>mainwindow.obj : warning LNK4217: locally defined symbol 
?ResetCamera at vtkRenderer@@QAEXXZ (public: void __thiscall 
vtkRenderer::ResetCamera(void)) imported in function "public: __thiscall 
MainWindow::MainWindow(void)" (??0MainWindow@@QAE at XZ)
1>mainwindow.obj : warning LNK4217: locally defined symbol 
?AddActor at vtkRenderer@@QAEXPAVvtkProp@@@Z (public: void __thiscall 
vtkRenderer::AddActor(class vtkProp *)) imported in function "public: __thiscall 
MainWindow::MainWindow(void)" (??0MainWindow@@QAE at XZ)
1>mainwindow.obj : warning LNK4217: locally defined symbol 
?RotateZ at vtkProp3D@@QAEXN at Z (public: void __thiscall vtkProp3D::RotateZ(double)) 
imported in function "public: __thiscall MainWindow::MainWindow(void)" 
(??0MainWindow@@QAE at XZ)
1>mainwindow.obj : warning LNK4217: locally defined symbol 
?RotateX at vtkProp3D@@QAEXN at Z (public: void __thiscall vtkProp3D::RotateX(double)) 
imported in function "public: __thiscall MainWindow::MainWindow(void)" 
(??0MainWindow@@QAE at XZ)
1>mainwindow.obj : warning LNK4217: locally defined symbol 
?SetColor at vtkProperty@@QAEXNNN at Z (public: void __thiscall 
vtkProperty::SetColor(double,double,double)) imported in function "public: 
__thiscall MainWindow::MainWindow(void)" (??0MainWindow@@QAE at XZ)
1>mainwindow.obj : warning LNK4217: locally defined symbol 
?GetProperty at vtkActor@@QAEPAVvtkProperty@@XZ (public: class vtkProperty * 
__thiscall vtkActor::GetProperty(void)) imported in function "public: __thiscall 
MainWindow::MainWindow(void)" (??0MainWindow@@QAE at XZ)
1>mainwindow.obj : warning LNK4217: locally defined symbol 
?New at vtkActor@@SAPAV1 at XZ (public: static class vtkActor * __cdecl 
vtkActor::New(void)) imported in function "public: __thiscall 
MainWindow::MainWindow(void)" (??0MainWindow@@QAE at XZ)
1>mainwindow.obj : warning LNK4217: locally defined symbol 
?GetOutputPort at vtkAlgorithm@@QAEPAVvtkAlgorithmOutput@@H at Z (public: class 
vtkAlgorithmOutput * __thiscall vtkAlgorithm::GetOutputPort(int)) imported in 
function "public: __thiscall MainWindow::MainWindow(void)" (??0MainWindow@@QAE at XZ)
1>mainwindow.obj : warning LNK4217: locally defined symbol 
?New at vtkPolyDataMapper@@SAPAV1 at XZ (public: static class vtkPolyDataMapper * 
__cdecl vtkPolyDataMapper::New(void)) imported in function "public: __thiscall 
MainWindow::MainWindow(void)" (??0MainWindow@@QAE at XZ)
1>mainwindow.obj : warning LNK4217: locally defined symbol 
?New at vtkRenderer@@SAPAV1 at XZ (public: static class vtkRenderer * __cdecl 
vtkRenderer::New(void)) imported in function "public: __thiscall 
MainWindow::MainWindow(void)" (??0MainWindow@@QAE at XZ)
1>mainwindow.obj : warning LNK4217: locally defined symbol 
??0QVTKWidget@@QAE at PAVQWidget@@V?$QFlags at W4WindowType@Qt@@@@@Z (public: 
__thiscall QVTKWidget::QVTKWidget(class QWidget *,class QFlags<enum 
Qt::WindowType>)) imported in function "public: __thiscall 
MainWindow::MainWindow(void)" (??0MainWindow@@QAE at XZ)
1>mainwindow.obj : warning LNK4217: locally defined symbol ??1QVTKWidget@@UAE at XZ 
(public: virtual __thiscall QVTKWidget::~QVTKWidget(void)) imported in function 
"public: virtual void * __thiscall QVTKWidget::`scalar deleting 
destructor'(unsigned int)" (??_GQVTKWidget@@UAEPAXI at Z)
1>mainwindow.obj : error LNK2019: unresolved external symbol 
"__declspec(dllimport) public: static class vtkCylinderSource * __cdecl 
vtkCylinderSource::New(void)" (__imp_?New at vtkCylinderSource@@SAPAV1 at XZ) 
referenced in function "public: __thiscall MainWindow::MainWindow(void)" 
(??0MainWindow@@QAE at XZ)
1>release\QVTK_test-static.exe : fatal error LNK1120: 1 unresolved externals

I'm focussing on this because the vtkCylinderSource link error also occurs when 
I build the application that I originally posted about.  This current example 
looks more tractable because there is only this single error.

I've looked carefully at the Project Properties for the Cylinder build, and I've 
made sure that the QVTK_test Properties are the same, or as close as possible 
(my program uses Qt, so there are additional libraries and include directories). 
  I am using exactly the same libraries, in the same order (except for the extra 
Qt libraries).  All to no avail - I still get the unresolved external symbol 
error for vtkCylinderSource::New(void).

I've been ignoring the warnings, because I don't understand them.  Maybe they 
are significant.



More information about the vtkusers mailing list